internal void AddRetryTask(ProxyOutgoingAsyncBase outAsync, int interval) { lock (_mutex) { if (_state == StateDestroyed) { throw new CommunicatorDestroyedException(); } var task = new RetryTask(this, outAsync); outAsync.Cancelable(task); // This will throw if the request is canceled. _timer.Schedule(task, interval); _requests.Add(task, null); } }
internal void RemoveRetryTask(RetryTask task) { lock (_mutex) { if (_requests.Remove(task)) { if (_state > StateActive && _requests.Count == 0) { // If we are destroying the queue, destroy is probably waiting on the queue to be empty. System.Threading.Monitor.Pulse(_mutex); } } } }
internal bool CancelRetryTask(RetryTask task) { lock (_mutex) { if (_requests.Remove(task)) { if (_state < StateDestroyInProgress) { return(_timer.Cancel(task)); } else if (_requests.Count == 0) { // If we are destroying the queue, destroy is probably waiting on the queue to be empty. System.Threading.Monitor.Pulse(_mutex); } } return(false); } }