/// <summary> /// OnAbort event /// </summary> protected override void OnAbort() { WCFLogger.Write(TraceEventType.Start, "Mail request channel starting to abort..."); lock (_stateLock) { base.OnAbort(); _wasAborted = true; AbortAllDequeueing(); WCFLogger.Write(TraceEventType.Verbose, "Mail request channel aborted all dequeueing."); lock (_asyncRequests) { // Wait for all threads to die foreach (KeyValuePair <object, AsyncRequest> kvp in _asyncRequests) { IAsyncResult result = _asyncResults[kvp.Key]; kvp.Value.EndInvoke(result); WCFLogger.Write(TraceEventType.Verbose, "Mail request channel aborted a thread."); } _asyncRequests.Clear(); _asyncResults.Clear(); } // Stop listening to the mailbox if (_mailHandler.InboxState == InboxState.Listening) { _mailHandler.Close(); } WCFLogger.Write(TraceEventType.Verbose, "Mail request channel aborted mail handler"); } WCFLogger.Write(TraceEventType.Stop, "Mail request channel finished aborting."); }