IPIAsynchStatus2 Interface

                    

 

The IPIAsynchStatus2 interface is a secondary interface supported by the PIAsynchStatus object. The interface has a single property, CallCompleteEvent, a windows synchronization primitive event that can be used to be notified of the completion of an asynchronous call across threads.   

 

Remarks

The PIAsynchStatus object supports Windows events that can be used to track progress and status of an asynchronous call.  These Windows events, however, are only reliably delivered in a single threaded application.  Though a multi-threaded application can still use polling, checking the status to determine when a call is complete, this interface exposes an alternate way to detect call completion across threads without having to poll. 

 

Synchronization primitives, in this case a Windows Event object (event is a heavily overloaded term), can be tracked using the Win32 call WaitForSingleObject.  With this call you can control how long you wait for an answer so you can spawn a thread that waits until the object is signaled or you can check if it has been signaled periodically. 

 

Another benefit of using the synchronization event to check for call completion is that you can make several asynchronous calls and wait for all of them to return using the Win32 call WaitForMultipleObjects.   This call can be used to wait for an array of event objects to complete before returning or can return when any of the objects has been signalled.  

Enabling Operational Intelligence