| Keysight.Visa Namespace > VisaSession Class > LockResource Method : LockResource(Int32,String) Method |
'DeclarationPublic Overloads Function LockResource( _ ByVal timeoutMilliseconds As Integer, _ ByVal sharedKey As String _ ) As String
'UsageDim instance As VisaSession Dim timeoutMilliseconds As Integer Dim sharedKey As String Dim value As String value = instance.LockResource(timeoutMilliseconds, sharedKey)
public string LockResource( int timeoutMilliseconds, string sharedKey )
public: String^ LockResource( int timeoutMilliseconds, String^ sharedKey )
This overload specifies a shared key, and will obtain a shared lock. Once a shared lock has been granted, any request for a shared lock with a different shared key will fail. However, a request for an exclusive lock may succeed.
This overload of LockResource returns after either acquiring the lock, or after waiting for the amount of time specified by the timeout.
A calling program can pass null or the empty string for the sharedKey parameter, in which case this method will generate a unique access key and return it as the return value. If a user application does specify a sharedKey value, the method will try to use this value as the shared key value.
If the resource is not locked, this method will use the sharedKey as the access key and grant the lock. When the operation succeeds, the sharedKey will also be returned as the method's return value, and VISA will add the session to the list of sessions sharing the lock for the particular resource. The session obtaining a shared lock in this manner will then have the same access privileges as the first session that obtained the lock.
This overload supports nested shared 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.
Current with Keysight IO Libraries Suite 18