Session Reference Counting
- Updated2023-02-21
- 2 minute(s) read
NI Switch Executive uses a reference counting scheme to manage open session handles to an NI Switch Executive virtual device. Each call to the niSE Open Session VI or the niSE_OpenSession function must be matched with a subsequent call to the niSE Close Session VI or the niSE_CloseSession function.
Multiple calls to the niSE Open Session VI or the niSE_OpenSession function with the same virtual device name always return the same session handle. Only after all session handles are closed to a given virtual device can NI Switch Executive disconnect its communication with the IVI switches. Session handles can be used safely in multiple threads of an application.
![]() |
Note When using an NI Switch Executive virtual device in an ADE, always allow the application to complete its call to the niSE Close Session VI or the niSE_CloseSession function. If you abort or halt the execution of your program before calling the niSE Close Session VI or the niSE_CloseSession function, the application may leave the session open. When a session remains open, all previous connections continue to exist. |
![]() |
Tip If you are debugging and prefer not to call the niSE Close Session VI or the niSE_CloseSession function, you can call the niSE Disconnect All VI or niSE_DisconnectAll function immediately after calling the niSE Open Session VI or the niSE_OpenSession function to ensure a known startup state. |