User`s guide

66 Agilent VISA User’s Guide
3 Programming with VISA
ViStatus _VI_FUNCH my_handler (ViSession vi,
ViEventType eventType, ViEvent context, ViAddr
usrHandle) {
/* your event handling code here */
return VI_SUCCESS;
}
main(){
ViSession vi;
ViAddr addr=0;
.
.
viInstallHandler(vi, VI_EVENT_SERVICE_REQ,
my_handler, addr);
viEnableEvent(vi, VI_EVENT_SERVICE_REQ,
VI_HNDLR, VI_NULL);
.
/* your code here */
.
viDisableEvent(vi, VI_EVENT_SERVICE_REQ,
VI_HNDLR);
viUninstallHandler(vi, VI_EVENT_SERVICE_REQ,
my_handler, addr);
.
}
Installing Handlers
VISA allows applications to install multiple handlers for an
event type on the same session. Multiple handlers can be
installed through multiple invocations of the
viInstallHandler operation, where each invocation adds to
the previous list of handlers.
If more than one handler is installed for an event type, each
of the handlers is invoked on every occurrence of the
specified event(s). VISA specifies that the handlers are
invoked in Last In First Out (LIFO) order. Use the following
function when installing an event handler: