public void HandleMessage(IMessage message) { switch (message) { case TimerAddCallbackMessage timerAddCallbackMessage: AddToQueue(new TimerCallback(timerAddCallbackMessage)); break; case TimerRemoveCallbackMessage timerRemoveCallbackMessage: lock (_set) _set.Add(new TimerCallback(timerRemoveCallbackMessage.Source, timerRemoveCallbackMessage.RequestId, null)); break; case TimerRetryGossipMessage retryGossipMessage: AddToQueue(new TimerCallback( TimerCallback.ComputeDelayedTimestamp(retryGossipMessage.TimeStamp, retryGossipMessage.Delay), typeof(GossipModule), retryGossipMessage.RequestId, () => _executor.AddMessage( new GossipRetryMessage(typeof(GossipModule), retryGossipMessage.Guid)))); break; default: throw new ArgumentOutOfRangeException(nameof(message)); } }