private void EndPointDestroyedEventHandler(object sender, AdapterEndPointEventArgs e) { TcpAdapterEndPoint endPoint = (TcpAdapterEndPoint)e.EndPoint; VocollectSession session = null; lock (endPointDictionary) { if (endPointDictionary.ContainsKey(endPoint)) { session = endPointDictionary[endPoint]; endPointDictionary.Remove(endPoint); } } if (session != null) { try { if (endPoint.Exception != null) { session.ReleaseLock(false); /* Do not log ObjectDisposedException since this indicates we got a timeout */ if (!(endPoint.Exception is ObjectDisposedException)) { if ((MessageEngine.Instance.Tracing.Switch.Level & SourceLevels.Error) == SourceLevels.Error) { MessageEngine.Instance.Tracing.TraceData(TraceEventType.Error, 0, endPoint.Exception); } } } else { session.ReleaseLock(true); } } catch (ObjectDisposedException) { //Session has been disposed } } }