Event Context with the Callback Mechanism

NI-VISA

Event Context with the Callback Mechanism

In the case of callbacks, the event is passed to you in a function, so the VISA driver has a chance to destroy it when the function ends. This has two important repercussions. First, you do not need to call viClose() on the event inside the callback function. Indeed, calling this operation on the event could lead to serious problems because VISA will access the event (to close it) when your callback returns. Secondly, the event itself has a life only as long as the callback function is executing. Therefore, if you want to keep any information about the event after the callback function, you should use viGetAttribute() to retrieve the information for storage. Any references to the event itself becomes invalid when the callback function ends.