AcquireInterfaceLock Method

NI-488.2 .NET Class Library Help for Visual Studio 2010

Edition Date: August 2012

Part Number: 370628F-01

»View Product Info
Download Help (Windows Only)

Board Class See Also


Attempts to acquire an exclusive lock on the interface for the current process.

Namespace: NationalInstruments.NI4882

Assembly: NationalInstruments.NI4882 (in NationalInstruments.NI4882.dll) Version: 13.0.40.159

Syntax

Visual Basic (Declaration)
Public Sub AcquireInterfaceLock ( _
	timeout As Integer _
)

C#
public void AcquireInterfaceLock(
	int timeout
)

Parameters

timeout
Type: System.Int32
Time period in milliseconds to wait for an exclusive lock.

Exceptions

ExceptionCondition
GpibException The NI-488.2 driver returns an error as a result of calling this method.
DllNotFoundException The NI-488.2 driver library cannot be found.
EntryPointNotFoundException A required operation in the NI-488.2 driver library cannot be found.
InvalidOperationException

The inner exception is set to the GpibException due to one of the following conditions:

Locks are not supported in the current NI-488.2 driver you are using.

-or-

Maximum reference count for the Board object has been reached.

-or-

Unable to acquire the requested lock within the timeout period because a different process owns a lock for the interface.

-or-

Nonexistent GPIB interface.

-or-

Asynchronous I/O operation in progress.

ObjectDisposedException This member is called after the Dispose method has been called directly from your code or indirectly through a finalizer.

Remarks

If a process has acquired a lock, all GPIB calls by that process for that interface occur normally.

If a process has acquired a lock, all GPIB calls (except AcquireInterfaceLock and ReleaseInterfaceLock) by other processes for that interface fail immediately and throw InvalidOperationException. AcquireInterfaceLock calls by other processes attempt to acquire a lock. The process throws an InvalidOperationException only after the timeout period has elapsed. AcquireInterfaceLock throws an InvalidOperationException, but returns a valid Board object.

Interface locks are exclusive and are not shareable among processes. If a process has a lock for an interface, no other process can acquire a lock associated with that interface.

A process may acquire multiple (redundant) locks on an interface. The NI-488.2 driver maintains a reference count of the number of outstanding locks per interface and does not unlock the interface until the reference count is 0. If the AcquireInterfaceLock call is successful—that is, if it does not return an exception—LastCount contains the number of locks remaining in effect for the Board object.

An interface lock is associated with a process and a GPIB interface. An acquired lock remains in effect until the lock is released. Each successful call to acquire a lock should have a corresponding call to release the lock. Calling Dispose releases all interface locks held by that process for the interface described by the Board object.

A timeout of 0 specifies a 0 ms wait period. If the interface is locked by another process, AcquireInterfaceLock returns immediately with InvalidOperationException. Otherwise, the process acquires the lock and returns.

See Also

Reference

Board Class

NationalInstruments.NI4882 Namespace

WAS THIS ARTICLE HELPFUL?

Not Helpful