static void TriggerException(MessageException e) { lock (_listenersLockObject) { ArrayList toBeDeleted = new ArrayList(); foreach (object key in _listeners.Keys) { AsyncResult myAr = (AsyncResult)_listeners[key]; if (myAr != null && myAr.Connection == e.Connection) { myAr.Complete(e); toBeDeleted.Add(myAr); } } foreach (object o in toBeDeleted) _listeners.Remove(o); } e.Connection.Close(); }