Closing a Session
- Updated2024-10-09
- 1 minute(s) read
RFmx provides the following methods to close a session.
public void Dispose() public void Close() public void ForceClose()
The Dispose and Close methods perform a reference counted close.
The following snippets show an example of closing a session using the Close method.
C#
//ref count is 0 RFmxInstrMX InstrSession1 = RFmxInstrMX.GetSession("Rfsa","");
RFmxInstrMX InstrSession2 = RFmxInstrMX.GetSession("Rfsa","");
RFmxInstrMX InstrSession3 = RFmxInstrMX.GetSession("Rfsa",""); //ref count is 3
InstrSession1.Close(); //ref count is 2. Session is not disposed yet.
InstrSession2.Close(); InstrSession3.Close(); //Session is closed when ref count hits 0.
VB
'ref count is 0 Dim InstrSession1 As RFmxInstrMX = RFmxInstrMX.GetSession("Rfsa", "")
Dim InstrSession2 As RFmxInstrMX = RFmxInstrMX.GetSession("Rfsa", "")
Dim InstrSession3 As RFmxInstrMX = RFmxInstrMX.GetSession("Rfsa", "") 'ref count is 3
InstrSession1.Close() 'ref count is 2. Session is not disposed yet.
InstrSession2.Close()
InstrSession3.Close() 'Session is closed when ref count hits 0.
The ForceClose method closes a session irrespective of the reference count. The following snippets show an example of closing a session using the ForceClose method.
C#
//ref count is 0 RFmxInstrMX InstrSession1 = RFmxInstrMX.GetSession("Rfsa","");
RFmxInstrMX InstrSession2 = RFmxInstrMX.GetSession("Rfsa","");
RFmxInstrMX InstrSession3 = RFmxInstrMX.GetSession("Rfsa",""); //ref count is 3
InstrSession1.ForceClose(); //Session is closed irrespective of reference count.
VB
'ref count is 0 Dim InstrSession1 As RFmxInstrMX = RFmxInstrMX.GetSession("Rfsa", "")
Dim InstrSession2 As RFmxInstrMX = RFmxInstrMX.GetSession("Rfsa", "")
Dim InstrSession3 As RFmxInstrMX = RFmxInstrMX.GetSession("Rfsa", "") 'ref count is 3
InstrSession1.ForceClose() 'Session is closed irrespective of reference count.