///////////////////////////////////////////////////////////////////////////////////////////////// // // RemoveSampleFocusEventHandler() // // Perform all cleanup of objects that we initialized on startup in the background thread. // // Runs on the background thread. // ///////////////////////////////////////////////////////////////////////////////////////////////// void RemoveSampleFocusEventHandler() { // If we successfully added an event handler earlier, remove it now. The // handler must be removed on the same thread on which it was added. if (_fAddedEventHandler) { // Depending on the timing of events generated around the time we remove // the event handler, an event can arrive at the handler after a successful // call to remove the event handler. So set the flag here to prevent our // event handler from taking any more action if futher calls to our event // handler are made. _fAddedEventHandler = false; _automation.RemoveFocusChangedEventHandler(this); } }