lockDuration

Type: Integer

The read-only lockDuration property of the LockException class contains the duration of the lock that was encountered in a multiuser environment.

The lock durations (whose values are provided by global constants in the LockDurations category) that can raise exceptions are listed in the following table.

Global Constant Integer
Persistent_Duration 2
Session_Duration 1
Transaction_Duration 0

The following example shows the use of the lockDuration property.

handleLockException(le: LockException): Integer;
//Example using tryLock to retry a lock
vars
    result  : Integer;
    message : String;
begin
    message := 'Cannot get lock for ' & le.lockTarget.String &
               '. It is locked by user ' ;
    result := app.msgBox('Lock Error', message & le.targetLockedBy.userCode
              & '. Retry?', MsgBox_Question_Mark_Icon + MsgBox_Yes_No);
    if result = MsgBox_Return_Yes then
        app.mousePointer := Busy;
        while not tryLock(le.lockTarget, le.lockType, le.lockDuration,
                          LockTimeout_Server_Defined) do
            app.mousePointer := Idle;
            result := app.msgBox('Lock Error', message &
                      le.targetLockedBy.userCode & '. Retry?',
                      MsgBox_Question_Mark_Icon + MsgBox_Yes_No);
            if result = MsgBox_Return_No then
                return Ex_Abort_Action;
            endif;
        app.mousePointer := Busy;
        endwhile;
        return Ex_Resume_Next;
    endif;
    return Ex_Abort_Action;
epilog
    app.mousePointer := Idle;
end;