lock(lockTarget: Object; lockType: Integer; lockDuration: Integer; timeout: Integer);
The lock method of the Object class acquires the type of lock specified in the lockType parameter for the object specified in the lockTarget parameter.
The duration and time of the lock are specified by the lockDuration and timeout parameters, respectively. (The timeout parameter specifies the number of milliseconds for the timeout.)
The following table lists the lock type, lock duration, and timeout global constant values.
Global Constant | Integer Value | Category |
---|---|---|
Exclusive_Lock | 3 |
|
Reserve_Lock | 2 |
|
Share_Lock | 1 |
|
Update_Lock | 4 |
|
Persistent_Duration | 2 |
|
Session_Duration | 1 |
|
Transaction_Duration | 0 |
|
LockTimeout_Immediate | -1 |
|
LockTimeout_Infinite | Max_Integer (#7FFFFFFF) |
|
LockTimeout_Process_Defined | -2 (use the process‑defined default) |
|
LockTimeout_Server_Defined | 0 (use the server-defined default) |
|
The following example shows the use of the lock method.
createMe(newname, newadd1, newadd2, newadd3: String; newcash: Decimal) updating; begin exclusiveLock(self); on LockException do alreadyInUse(exception); lock(self, Exclusive_Lock, Transaction_Duration, 100); self.name := newname; self.address1 := newadd1; self.address2 := newadd2; self.address3 := newadd3; if newcash = 0 then self.cash := 100000; else self.cash := newcash; endif; self.myMarket := app.myMarket; end;