Waiting on Events with ''isc wait for event()''

From InterBase
Jump to: navigation, search

After setting up EPBs and specifying events of interest with isc_event_block(), an application can use isc_wait_for_event() to register interest in those events and pause its execution until one of the events occurs.

Important: isc_wait_for_event() cannot be used in Microsoft Windows applications or under any other operating system that does not permit processes to pause. Applications on these platforms must use asynchronous event handling.

The syntax for isc_wait_for_event() is:

ISC_STATUS isc_wait_for_event(ISC_STATUS *status_vector, isc_db_handle
*db_handle,

For example, the following code sets up EPBs for three events, then calls isc_wait_for_event() to suspend its execution until one of the events occurs:

#include <ibase.h>;
. . .
char *event_buffer, *result_buffer;
long blength;
ISC_STATUS status_vector[20];
isc_db_handle db1;
. . .
/* Assume database db1 is attached here and a transaction started. */
blength = isc_event_block(&event_buffer, &result_buffer, 3, "BORL",
"INTEL", "SUN");
isc_wait_for_event(status_vector, &db1, (short)blength,
event_buffer, result_buffer);
/* Application processing is suspended here until an event occurs. */
. . .

Once isc_wait_for_event() is called, application processing stops until one of the requested events is posted. When the event occurs, application processing resumes at the next executable statement following the call to isc_wait_for_event(). If an application is waiting on more than one event, it must use isc_event_counts() to determine which event was posted.

Note: A single call to isc_wait_for_event() can wait on a maximum of 15 events. Applications that need to wait on more than 15 events must wait on one set of 15, then make another call to isc_wait_for_event() to wait on additional events.

For the complete syntax of isc_wait_for_event(), see isc_wait_for_event().

Advance to Next Topic