//! Making sure all internal processing has stopped in an object using a //! callQueue: //! First, ensure that all users of the object have been shut down or detached. //! Then make sure that internal processing has been shut down in the object. //! Then ensure that all enqueued dispatch calls have been flushed //! by calling WaitForPendingCalls. void WaitForPendingCalls(bool bInvokedOnDispatchThread) { if(bInvokedOnDispatchThread) { // CallQueue is running on the same thread as the Wait call. bool bCompleted; Enqueue(bind(&Impl::SetToTrue, ref(bCompleted))); while(!bCompleted) { const bool bBlock = false; Dispatch(bBlock); } } else { // CallQueue is running on a different thread than the Wait call. AutoResetEvent completedEvent; Enqueue(bind(&AutoResetEvent::Set, &completedEvent)); completedEvent.Wait(); } }