Event Context with the Queuing Mechanism

NI-VISA

Event Context with the Queuing Mechanism

When you use the queuing mechanism, the event context is returned when you call viWaitOnEvent(). The VISA driver has created this data structure, but it cannot destroy it until you tell it to. For this reason, in VISA you call viClose() on the event context so the driver can free the memory for you. Always remember to call viClose() when you are done with the event.

If you know the type of event you are receiving, and the event does not provide any useful information to your application other than whether it actually occurred, you can pass VI_NULL as the outEventType and eventContext parameters as shown in the following example:

status = viWaitOnEvent(gpibSesn, VI_EVENT_SERVICE_REQ, 5000, VI_NULL, VI_NULL);

In this case, VISA automatically closes the event data structure rather than returning it to you. Calling viClose() on the event context is therefore both unnecessary and incorrect because VISA would not have returned the event context to you.