Click or drag to resize

ObtainLock

This macro obtains a thread-based lock for the specified session for the duration of the function in which it is declared.

#define ObtainLock(Vi)
Parameters
Vi

[in] ViSession handle for the driver session.

Remarks

This macro declares a local instance of a special SessionLock class. The constructor of the SessionLock class obtains a session lock on the session indicated by the Vi parameter. When the function containing the ObtainLock macro completes, the SessionLock destructor runs and the session is unlocked.

Example

The following example demonstrates use of the ObtainLock macro.

C++
ViStatus _VI_FUNC acme4321_ConfigureSweep(ViSession Vi, ViReal64 StartFrequency, ViReal64 StopFrequency)
{
    ObtainLock(Vi);

    // ...
}

Download a complete CHM version of this documentation here.