internal void AddRetryTask(ProxyOutgoingAsyncBase outAsync, int interval) { lock (this) { if (_state == StateDestroyed) { throw new CommunicatorDestroyedException(); } RetryTask 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 (this) { if (_requests.Remove(task)) { if (_state == StateDestroyed && _requests.Count == 0) { // If we are destroying the queue, destroy is probably waiting on the queue to be empty. System.Threading.Monitor.Pulse(this); } } } }
internal bool CancelRetryTask(RetryTask task) { lock (this) { if (_requests.Remove(task)) { if (_state == StateDestroyed && _requests.Count == 0) { // If we are destroying the queue, destroy is probably waiting on the queue to be empty. System.Threading.Monitor.Pulse(this); } return(_timer.Cancel(task)); } return(false); } }