public AttemptConnectRecoveryService(ILogger logger, RecoveryConfig config) { _logger = logger; _toRecover = new List <RecoveryItem>(); _timer = new Timer(config.Interval * 1000); _timer.Elapsed += (s, e) => TryRecover(); _timer.AutoReset = false; _lock = new object(); }
public AttemptConnectRecoveryService(ILogger logger, RecoveryConfig config) { _lock = new object(); _logger = logger; _toRecover = new List <RecoveryItem>(); taskCTS = new CancellationTokenSource(); var token = taskCTS.Token; if (config.Interval <= 0) { // not allow! at least 1. config.Interval = 1; } _recoveryTask = Task.Factory.StartNew( async() => { while (token.IsCancellationRequested == false) { TryRecover(); await Task.Delay(TimeSpan.FromSeconds(config.Interval), token); } }, TaskCreationOptions.LongRunning); }
public float PointDistance; // The distance threshold used to recover a point public bool IsEquivalentTo(RecoveryConfig c) { return(Timeout == c.Timeout && Math.Abs(TangibleDistance - c.TangibleDistance) < EpsilonAmt && Math.Abs(PointDistance - c.PointDistance) < EpsilonAmt); }