Obtains a logical
lock on a variable name.
Synopsis
The
Lock function has the following parameters:
Returns true if the lock was obtained, false otherwise.
Each time a lock is obtained on a
varname a lock
count is incremented for this
varname.
Unlock decrements
this count. Only when the lock count falls to zero will the logical lock be
released. For this reason, you should balance each call to
Lock with
a corresponding call to
Unlock.
The following example uses the
Lock function to
obtain a logical lock on a
varname with a timeout of 10
seconds.
If Lock(^PatientData(PatientID), 10) = True Then
Println "Got the Lock"
Unlock(^PatientData(PatientID))
Else
Println "Couldn't get the lock"
End If
If a
timeout is not specified,
Lock will
wait indefinitely for the lock to be obtained. Specifying a
timeout causes
the lock attempt to wait up to the timeout number of seconds to obtain the
lock.