public void Run() { _timer = new PeriodicTimer(obj => { var now = DateTime.UtcNow; var nativeApp = ((ApplicationHost)_appHost).NativeApp; try { if (_sessionManager.Sessions.Any(i => (now - i.LastActivityDate).TotalMinutes < 15)) { nativeApp.PreventSystemStandby(); } else { nativeApp.AllowSystemStandby(); } } catch (Exception ex) { _logger.ErrorException("Error resetting system standby timer", ex); } }, null, TimeSpan.FromMinutes(5), TimeSpan.FromMinutes(5)); }
public void Run() { LoadCachedAddress(); _timer = new PeriodicTimer(TimerCallback, null, TimeSpan.FromSeconds(5), TimeSpan.FromHours(1)); ((ConnectManager)_connectManager).Start(); }
public void Dispose() { if (_timer != null) { _timer.Dispose(); _timer = null; } }
public void Run() { _timer = new PeriodicTimer(obj => { var now = DateTime.UtcNow; if (_sessionManager.Sessions.Any(i => (now - i.LastActivityDate).TotalMinutes < 15)) { KeepAlive(); } }, null, TimeSpan.FromMinutes(5), TimeSpan.FromMinutes(5)); }
public void Run() { _timer = new PeriodicTimer(OnTimerFired, null, TimeSpan.FromMilliseconds(500), _frequency); }
private void Start() { _logger.Debug("Starting NAT discovery"); NatUtility.EnabledProtocols = new List<NatProtocol> { NatProtocol.Pmp }; NatUtility.DeviceFound += NatUtility_DeviceFound; // Mono.Nat does never rise this event. The event is there however it is useless. // You could remove it with no risk. NatUtility.DeviceLost += NatUtility_DeviceLost; // it is hard to say what one should do when an unhandled exception is raised // because there isn't anything one can do about it. Probably save a log or ignored it. NatUtility.UnhandledException += NatUtility_UnhandledException; NatUtility.StartDiscovery(); _timer = new PeriodicTimer(ClearCreatedRules, null, TimeSpan.FromMinutes(5), TimeSpan.FromMinutes(5)); _ssdp.MessageReceived += _ssdp_MessageReceived; _lastConfigIdentifier = GetConfigIdentifier(); _isStarted = true; }
private void DisposeNat() { _logger.Debug("Stopping NAT discovery"); if (_timer != null) { _timer.Dispose(); _timer = null; } _ssdp.MessageReceived -= _ssdp_MessageReceived; try { // This is not a significant improvement NatUtility.StopDiscovery(); NatUtility.DeviceFound -= NatUtility_DeviceFound; NatUtility.DeviceLost -= NatUtility_DeviceLost; NatUtility.UnhandledException -= NatUtility_UnhandledException; } // Statements in try-block will no fail because StopDiscovery is a one-line // method that was no chances to fail. // public static void StopDiscovery () // { // searching.Reset(); // } // IMO you could remove the catch-block catch (Exception ex) { _logger.ErrorException("Error stopping NAT Discovery", ex); } finally { _isStarted = false; } }
/// <summary> /// Runs this instance. /// </summary> public void Run() { _timer = new PeriodicTimer(s => LoadAllRegistrations(), null, TimeSpan.FromMilliseconds(100), TimeSpan.FromHours(12)); }
public void Run() { Task.Run(() => LoadCachedAddress()); _timer = new PeriodicTimer(TimerCallback, null, TimeSpan.FromSeconds(5), TimeSpan.FromHours(3)); }