public void Start() { InitializeAssetPairs(); _reconnectIfNeededTrigger.Start(); _forceReconnectTrigger.Start(); }
public async Task TimerTrigger_stop_cancels_handler_execution() { // Arrange var timer = new TimerTrigger("TestTimer", TimeSpan.FromMilliseconds(100), new LogToConsole()); var wasCancellationRequested = false; // Act timer.Start(); timer.Triggered += (trigger, args, token) => { var sw = Stopwatch.StartNew(); while (sw.Elapsed < TimeSpan.FromSeconds(5)) { if (token.IsCancellationRequested) { wasCancellationRequested = true; break; } } sw.Stop(); return(Task.CompletedTask); }; await Task.Delay(500); timer.Stop(); // Assert Assert.True(wasCancellationRequested); }
public void Start() { if (_enableAutoUpdate) { _timer = new TimerTrigger(nameof(TradeHistoryService), TimeSpan.FromMinutes(1), _logFactory, DoTimer); _timer.Start(); } }
public void Start() { if (PublisherSettings == null || PublisherSettings.ChatId == 0) { return; } _timer.Start(); Log.Info($"Start work ChatPublisher: {this.GetType().FullName} with timeout: {PublisherSettings?.TimeSpan}"); }
public void Start() { var settings = _settings.GetAllSettings().GetAwaiter().GetResult(); foreach (ISimBaseInstrumentSetting setting in settings) { var item = new SimBaseInstrumentService(_orderBookProvider, _tickPriceProvider, _tickPriceStore, setting, _commissionSettingRepository, _logFactory); _services.Add(item); } _timerTrigger.Start(); }
public StreamService(ILogFactory logFactory, bool needPing = false) { if (needPing) { _checkTimer = new TimerTrigger(nameof(StreamService <T>), TimeSpan.FromSeconds(10), logFactory); _checkTimer.Triggered += CheckStreams; _checkTimer.Start(); _pingTimer = new TimerTrigger(nameof(StreamService <T>), TimeSpan.FromMinutes(1), logFactory); _pingTimer.Triggered += Ping; _pingTimer.Start(); } }
public EthNodeClientBase(Func <Task <string[]> > connStringListGetter, ILogFactory log, TimeSpan?webSocketConnectionTimeout) { _connStringListGetter = connStringListGetter; _log = log.CreateLog(this); _nethereumLog = log.CreateNethereumLog(this); UpdateConnectionList(connStringListGetter.Invoke().Result); SetActiveConnectionPool(); _timer = new TimerTrigger(GetType().Name, TimeSpan.FromSeconds(300), log, TimerHandler); _timer.Start(); // setting up timeout for websocket connections ClientBase.ConnectionTimeout = webSocketConnectionTimeout ?? TimeSpan.FromSeconds(DefaultWebSocketConnectionTimeoutInSeconds); }
public async Task TimerTrigger_can_be_run_without_event_handler() { // Arrange var timer = new TimerTrigger("TestTimer", TimeSpan.FromMilliseconds(100), new LogToConsole()); // Act timer.Start(); await Task.Delay(500); timer.Stop(); // Assert }
public StreamServiceBase(ILogFactory logFactory, bool needPing = false) { _log = logFactory.CreateLog(this); _checkTimer = new TimerTrigger($"StreamService<{nameof(T)}>", TimeSpan.FromSeconds(10), logFactory); _checkTimer.Triggered += CheckStreams; _checkTimer.Start(); if (needPing) { _pingTimer = new TimerTrigger($"StreamService<{nameof(T)}>", TimeSpan.FromSeconds(30), logFactory); _pingTimer.Triggered += Ping; _pingTimer.Start(); } }
public void Start() { _cancellationTokenSource = new CancellationTokenSource(); _cancellationToken = _cancellationTokenSource.Token; var timeUntilMidnight = DateTime.UtcNow.Date.AddDays(1) - DateTime.UtcNow; _log.Info($"Total tokens periodical handler will start at {DateTime.UtcNow.Add(timeUntilMidnight)}"); Task.Delay(timeUntilMidnight, _cancellationToken) .ContinueWith((t) => { if (!t.IsCanceled) { _timerTrigger.Start(); } }); }
public void Start() { _cancellationTokenSource = new CancellationTokenSource(); _cancellationToken = _cancellationTokenSource.Token; var timeUntilNextWholeHour = GetTimeToNextWholeMinute(); _log.Info($"Time Handler will start at {DateTime.UtcNow.Add(timeUntilNextWholeHour)}"); Task.Delay(timeUntilNextWholeHour, _cancellationToken) .ContinueWith((t) => { if (t.IsCanceled) return; _timerTrigger.Start(); }, _cancellationToken); }
public StreamServiceBase(ILogFactory logFactory, bool needPing = false, TimeSpan?jobPeriod = null) { _log = logFactory.CreateLog(this); _checkTimer = new TimerTrigger($"StreamService<{nameof(T)}>", TimeSpan.FromSeconds(10), logFactory); _checkTimer.Triggered += CheckStreams; _checkTimer.Start(); if (jobPeriod.HasValue) { _jobTimer = new TimerTrigger($"StreamService<{nameof(T)}>", jobPeriod.Value, logFactory); _jobTimer.Triggered += Job; _jobTimer.Start(); } if (needPing) { _pingTimer = new TimerTrigger($"StreamService<{nameof(T)}>", TimeSpan.FromSeconds(30), logFactory); _pingTimer.Triggered += Ping; _pingTimer.Start(); } }
public async Task TimerTrigger_event_triggered_many_times() { // Arrange var timer = new TimerTrigger("TestTimer", TimeSpan.FromMilliseconds(100), new LogToConsole()); var triggeredCount = 0; timer.Triggered += (trigger, args, token) => { ++triggeredCount; return(Task.CompletedTask); }; // Act timer.Start(); await Task.Delay(500); timer.Stop(); // Assert Assert.True(triggeredCount > 1); }
public void Start() { _timerTrigger.Start(); }
public void Start() { Initialize(); // top assets and weights from the last history state _trigger.Start(); }
public void Start() { _timer = new TimerTrigger(GetType().Name, Interval, _logFactory, Handler); _timer.Start(); }
public void Start() { _timer.Start(); }
public void Start() { _maintainTicker.Start(); }
public void Start() { _log.Info("Starting"); _timerTrigger.Start(); }
public void asyncWorker_asAsyncAction_should_return_an_executable_asyncAction_with_support_for_triggers() { var wa = new ManualResetEvent( false ); var asyncAction = AsyncWorker.Using( 5 ) .OnExecute( e => { Thread.Sleep( e.Argument ); } ); var timerTrigger = new TimerTrigger( 5, TimerTriggerMode.Once ); asyncAction.AddTrigger( timerTrigger ); timerTrigger.Start(); asyncAction.Completed += ( s, e ) => wa.Set(); var actual = wa.WaitOne( 500 ); // var actual = asyncAction.AsyncWaitHandle.WaitOne( 15 ); actual.Should().Be.True(); }
public void Start() { _trigger.Start(); }
public void Start() { _refreshTimer.Start(); }