Session Class

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

Edition Date: August 2012

Part Number: 370627F-01

»View Product Info
Download Help (Windows Only)

Members See Also


Serves as the base class for all VISA session objects.

Namespace: NationalInstruments.VisaNS

Assembly: NationalInstruments.VisaNS (in NationalInstruments.VisaNS.dll) Version: 13.0.40.167

Syntax

Visual Basic (Declaration)
Public Class Session _
	Inherits MarshalByRefObject _
	Implements IDisposable, ISynchronizeCallbacks, ISupportSynchronizationContext

C#
public class Session : MarshalByRefObject, IDisposable, 
	ISynchronizeCallbacks, ISupportSynchronizationContext

Remarks

This class defines the basic functionality of the interaction with the VISA library, such as event-enabling, -disabling, -discarding, and -installing. You can also use Session to access common information for instruments and/or the underlying implementation of VISA.
Note: In the .NET interface to NI-VISA, a VISA session opens when Session or one of its subclasses is instantiated. A VISA session closes when Session or one of its subclasses is disposed by calling the Dispose method. Ensure that you call Dispose when you are finished with a session.

You cannot read from or write to an instrument or interface if you instantiate Session directly. Instead, you must instantiate one of the Session subclasses directly or indirectly. If you need functionality that is not specific to a hardware interface, you can instantiate MessageBasedSession or RegisterBasedSession directly. However, it is recommended that you instantiate a session indirectly with Open. This method returns the appropriate subclass instance automatically depending on the resource string that you pass as a parameter. The subclass instance is referenced by a generic Session object reference, but you can cast to the more specific type if you need the behavior.

Note: In some cases, callbacks and event handlers are executed in a different thread than the rest of the program. Therefore, you must take special care when accessing objects that have thread affinity, such as UI controls, from these callbacks and event handlers. For more information, refer to Events, Callbacks, and Thread Safety in Measurement Studio .NET Class Libraries.

Inheritance Hierarchy

System.Object
    System.MarshalByRefObject
        NationalInstruments.VisaNS.Session
            NationalInstruments.VisaNS.GpibInterface
            NationalInstruments.VisaNS.MessageBasedSession
            NationalInstruments.VisaNS.RegisterBasedSession
            NationalInstruments.VisaNS.VxiBackplane
            NationalInstruments.VisaNS.VxiSession

Thread Safety

All members of this type are safe for multithreaded operations.

See Also

Reference

Session Members

NationalInstruments.VisaNS Namespace

Session

Other Resources

WAS THIS ARTICLE HELPFUL?

Not Helpful