コード例 #1
0
        /// <summary>
        /// Schedules a failed node for reconnection.
        /// </summary>
        /// <param name="node"></param>
        protected virtual void ScheduleReconnect(INode node)
        {
            if (LogInfoEnabled)
            {
                log.Info("Scheduling reconnect for " + node.EndPoint);
            }

            var when = reconnectPolicy.Schedule(node);

            if (when == TimeSpan.Zero)
            {
                if (LogInfoEnabled)
                {
                    log.Info("Will reconnect now");
                }
                ReconnectNow(node);
            }
            else
            {
                if (LogInfoEnabled)
                {
                    log.Info("Will reconnect after " + when);
                }
                Task
                .Delay(when, shutdownToken.Token)
                .ContinueWith(_ => ReconnectNow(node), TaskContinuationOptions.OnlyOnRanToCompletion);
            }
        }
コード例 #2
0
        /// <summary>
        /// Schedules a failed node for reconnection.
        /// </summary>
        /// <param name="node"></param>
        protected virtual void ScheduleReconnect(INode node)
        {
            LogTo.Info($"Scheduling reconnect for {node}");

            var when = reconnectPolicy.Schedule(node);

            if (when == TimeSpan.Zero)
            {
                LogTo.Info("Will reconnect now");
                ReconnectNow(node);
            }
            else
            {
                LogTo.Info($"Will reconnect after {when}");
                Task
                .Delay(when, shutdownToken.Token)
                .ContinueWith(_ => ReconnectNow(node), TaskContinuationOptions.OnlyOnRanToCompletion);
            }
        }