Keysight VISA.NET Help
LockResource(TimeSpan) Method



If this resource is locked, the absolute time period to wait for the resource to be unlocked before throwing an exception. If the time span in milliseconds is 0, operations will never wait for the lock. If the time span is TimeSpan.MaxValue or the time span in milliseconds is greater than or equal to UInt32.MaxValue, the attempt to wait for the lock will never timeout. Negative time spans are not valid.
Acquires a lock on the resource for this session.
Syntax
'Declaration
 
Public Overloads Sub LockResource( _
   ByVal timeout As TimeSpan _
) 
'Usage
 
Dim instance As VisaSession
Dim timeout As TimeSpan
 
instance.LockResource(timeout)
public void LockResource( 
   TimeSpan timeout
)
public:
void LockResource( 
   TimeSpan timeout
) 

Parameters

timeout
If this resource is locked, the absolute time period to wait for the resource to be unlocked before throwing an exception. If the time span in milliseconds is 0, operations will never wait for the lock. If the time span is TimeSpan.MaxValue or the time span in milliseconds is greater than or equal to UInt32.MaxValue, the attempt to wait for the lock will never timeout. Negative time spans are not valid.
Remarks

Since this overload does not specify a shared key, it will obtain an exclusive lock. Once an exclusive lock has been granted, any request for a shared lock will fail.

This overload returns after either acquiring the lock, or after waiting for the amount of time specified by the timeout.

This overload supports nested exclusive locks. For each session, LockResource and UnlockResource share an internal lock count, which is initialized to 0. Each successful call to LockResource on the same session (and for the same lock type) increases the lock count. When a session locks the resource a multiple number of times, it is necessary to invoke the UnlockResource method an equal number of times in order to unlock the resource. That is, the lock count increments for each call to LockResource, and decrements for each call to UnlockResource. A resource is actually unlocked only when the lock count is 0.

If the session holds both exclusive and shared locks, successive calls to UnlockResource will first decrement the exclusive lock count to 0, and then the shared lock count.

Requirements

Current with Keysight IO Libraries Suite 18

See Also

 

 


© Keysight Technologies 2015-2025