示例#1
0
        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));
        }
示例#2
0
        public void Run()
        {
            LoadCachedAddress();

            _timer = new PeriodicTimer(TimerCallback, null, TimeSpan.FromSeconds(5), TimeSpan.FromHours(1));
            ((ConnectManager)_connectManager).Start();
        }
示例#3
0
 public void Dispose()
 {
     if (_timer != null)
     {
         _timer.Dispose();
         _timer = null;
     }
 }
示例#4
0
        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));
        }
示例#5
0
 public void Run()
 {
     _timer = new PeriodicTimer(OnTimerFired, null, TimeSpan.FromMilliseconds(500), _frequency);
 }
示例#6
0
        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;
        }
示例#7
0
        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;
            }
        }
示例#8
0
 /// <summary>
 /// Runs this instance.
 /// </summary>
 public void Run()
 {
     _timer = new PeriodicTimer(s => LoadAllRegistrations(), null, TimeSpan.FromMilliseconds(100), TimeSpan.FromHours(12));
 }
示例#9
0
        public void Run()
        {
            Task.Run(() => LoadCachedAddress());

            _timer = new PeriodicTimer(TimerCallback, null, TimeSpan.FromSeconds(5), TimeSpan.FromHours(3));
        }