CTBase.Lock
Syntax
void Lock(LOCK_MODE mode)
Parameters
Description
Enables or disables session-wide locks.
After a call to Lock with any mode but LOCK_MODE.LOCK_FREE, any record that becomes a current record will be locked. For instance, all records read after a call to Lock will be locked. Notice that in the moment Lock is called, no file or record is locked. Instead, a flag is set internally to indicate that all new records read will lock the record. To simply lock the current record, use CTRecord.LockRecord().
A record that is locked with one of the READ locks available allows any other user with a READ lock to read that record. No one can update a record using a READ lock. When a user gets a WRITE lock in a record, it means he/she may update that particular record, and until the record is freed, no one else is able to obtain any lock on that particular record. Yet anyone can still read the record.
If a record is read without any lock, it means that any other user can change the record contents. If a record is read with a READ lock, it means that any other user may still read the same record, but no user may obtain a WRITE lock, assuring the record will not be changed while a READ lock is kept on the record. When a record is read with a WRITE lock, the user who obtained the lock may update the record, but no other user may obtain a lock on the record.
A lock obtained with a call to CTBase.Lock(), no matter what object does the call, is always a Session lock, in the sense that any table operation after this call is subject to the locks.
A call to Abort(), Commit(), or Unlock() will release all session wide locks. A call to Lock with LOCK_MODE.LOCK_FREE also releases the session wide locks.
Return
None.
Example
Record1.Lock();
Record1.SetFieldAsString("name", "Johny Wild");
Record1.Find(FIND_MODE.EQ);
See Also
Unlock(), IsLockActive(), GetLockMode(), CTRecord.LockRecord(), Locking