void DeleteTimedoutRequestsFromCorrelator() { ICorrelatorKey[] array = null; if (timedOutRequests != null && timedOutRequests.Count > 0) { lock (ThisLock) { if (timedOutRequests != null && timedOutRequests.Count > 0) { array = timedOutRequests.ToArray(); timedOutRequests = null; } } } // Remove requests from the correlator since the channel might be either faulting, aborting or closing // We are not going to get a reply for these timed out requests. If they are not removed from the correlator, this will cause a leak. // This operation does not have to be under the lock if (array != null && array.Length > 0) { RequestReplyCorrelator requestReplyCorrelator = correlator as RequestReplyCorrelator; if (requestReplyCorrelator != null) { foreach (ICorrelatorKey request in array) { requestReplyCorrelator.RemoveRequest(request); } } } }
void AbortRequests() { IDuplexRequest[] array = null; lock (ThisLock) { if (requests != null) { array = requests.ToArray(); foreach (IDuplexRequest request in array) { request.Abort(); } } requests = null; requestAborted = true; } // Remove requests from the correlator since the channel might be either faulting or aborting, // We are not going to get a reply for these requests. If they are not removed from the correlator, this will cause a leak. // This operation does not have to be under the lock if (array != null && array.Length > 0) { RequestReplyCorrelator requestReplyCorrelator = correlator as RequestReplyCorrelator; if (requestReplyCorrelator != null) { foreach (IDuplexRequest request in array) { ICorrelatorKey keyedRequest = request as ICorrelatorKey; if (keyedRequest != null) { requestReplyCorrelator.RemoveRequest(keyedRequest); } } } } //if there are any timed out requests, delete it from the correlator table DeleteTimedoutRequestsFromCorrelator(); }