32 Global Call API for HMP on Windows Programming Guide — August 2006
Programming Models
Whereas default asynchronous programming uses the sr_waitevt() function to wait for events
specific to one device, extended asynchronous programming uses the sr_waitevtEx() functi on to
wait for events specific to a number of devices (channels).
Note: Do not use the sr_waitevtEx( ) function in combination with either the sr_waitevt( ) function or
event handlers.
This model can run an entire application using only a few threads. When an event is available, the
gc_GetMetaEventEx() function must be used to retrieve event-specific information. The values
returned are valid until the sr_waitevtEx() function is called again. Event commands can be
executed from the main thread through switch statements; the events are processed immediately.
The extended asynchronous model calls the sr_waitevtEx( ) function for a group of devices
(channels) and polls for (waits for) events specific to that group of devices. In this model, the SRL
event handler thread is not created (the SR_MODELTYPE value is set to SR_STASYNC) and the
sr_enbhdlr() function in not used.
In the extended asynchronous model, functions are initiated asynchronously from different threads.
A thread waits for events using the sr_waitevtEx() function. The event information can be
retrieved using the gc_GetMetaEventEx() function. When thi s function returns, the event
information is stored in the METAEVENT data structure.
Caution: When calling the gc_GetMetaEventEx( ) function from multiple threads, ensure that your
application uses unique thread-related METAEVENT data structures (thread local variables or
local variables), or ensure that the METAEVENT data structure is not overwritten until all
processing of the current event has completed.
The event information retrieved determines the exact event that occurred and is valid until the
sr_waitevtEx( ) function returns with another event.