Beispiel #1
0
        private void DisposeNat()
        {
            _logger.Debug("Stopping NAT discovery");

            if (_timer != null)
            {
                _timer.Dispose();
                _timer = null;
            }

            _deviceDiscovery.DeviceDiscovered -= _deviceDiscovery_DeviceDiscovered;

            try
            {
                NatUtility.StopDiscovery();
                NatUtility.DeviceFound -= NatUtility_DeviceFound;
                NatUtility.DeviceLost  -= NatUtility_DeviceLost;
            }
            catch (Exception ex)
            {
                _logger.ErrorException("Error stopping NAT Discovery", ex);
            }
            finally
            {
                _isStarted = false;
            }
        }
Beispiel #2
0
        private async Task <TimeSpan> OperationTelemetryHandler(Func <CancellationToken, Task <TimeSpan> > operation, CancellationToken token, [CallerMemberName] string memberName = "")
        {
            try
            {
                var operationEvent = new OperationTelemetryEvent(memberName);

                var result = await operation(token).ConfigureAwait(false);

                _telemetry.Publish(operationEvent);

                return(result);
            }
            catch (OperationCanceledException _)
            {
                _telemetry.Publish(new LeaseStoppedEvent(InstanceId, _options.Value.WorkerType, _options.Value.Priority));

                throw;
            }
            catch (Exception ex)
            {
                _timer.Dispose();

                _telemetry.Publish(new LeaseExceptionEvent(InstanceId, _options.Value.WorkerType, _options.Value.Priority,
                                                           ex.Message));

                throw new WorkerLeaseException(
                          $"An unhandled exception occurred executing operation [{memberName}]", ex);
            }
        }
Beispiel #3
0
        private void TimerEventTest(ITimer timer)
        {
            Console.WriteLine($"TimerEventTest {timer.GetType().Name}");
            timer.Interval = 5;
            timer.Start();

            Task.Run(() =>
            {
                var stopwatch = new HiResStopwatch();
                stopwatch.Start();

                var timerEvent = new TimerEvent(timer);
                var count      = 0;
                while (count++ < 400)
                {
                    timerEvent.WaitOne();
                    Console.WriteLine($"TimerEventTest TickCount {count}, Timer = {stopwatch.ElapsedMicroseconds:#,0} µs");
                }

                timerEvent.Dispose();
                stopwatch.Stop();
            }).Wait();

            Console.WriteLine("Stopping...");

            timer.Dispose();
        }
        private void DisposeNat()
        {
            _logger.LogDebug("Stopping NAT discovery");

            if (_timer != null)
            {
                _timer.Dispose();
                _timer = null;
            }

            _deviceDiscovery.DeviceDiscovered -= _deviceDiscovery_DeviceDiscovered;

            var natManager = _natManager;

            if (natManager != null)
            {
                _natManager = null;

                using (natManager)
                {
                    try
                    {
                        natManager.StopDiscovery();
                        natManager.DeviceFound -= NatUtility_DeviceFound;
                    }
                    catch (Exception ex)
                    {
                        _logger.LogError(ex, "Error stopping NAT Discovery");
                    }
                }
            }
        }
Beispiel #5
0
        /// <summary>
        /// Stop internal clock.
        /// </summary>
        /// <param name="warnIfNotStarted">use true to indicate whether to warn if the clock is not Started, use false to not warn
        /// and expect the clock to be not Started.</param>
        public void StopInternalClock(bool warnIfNotStarted)
        {
            if (_timer == null)
            {
                if (warnIfNotStarted)
                {
                    Log.Warn(".StopInternalClock Internal clock is already Stopped, Start first before Stopping, operation not completed");
                }
                return;
            }

            if (Log.IsDebugEnabled)
            {
                Log.Debug(".StopInternalClock Stopping internal clock daemon thread");
            }

            _timerTaskCancelled = true;
            _timer.Dispose();

            try
            {
                // Sleep for at least 100 ms to await the internal timer
                Thread.Sleep(100);
            }
            catch (ThreadInterruptedException)
            {
            }

            _timer = null;
        }
        public void Dispose()
        {
            #region Guard

            if (disposed)
            {
                return;
            }

            #endregion

            if (running)
            {
                // Stop the multimedia timer.
                timer.Stop();
            }

            disposed = true;

            timer.Dispose();

            GC.SuppressFinalize(this);

            OnDisposed(EventArgs.Empty);
        }
Beispiel #7
0
        public void Dispose()
        {
            lock (_syncRoot)
            {
                // Never do a dispose twice.
                if (_isDispsoed)
                {
                    return;
                }
                _isDispsoed = true;
            }

            // Dispose all members
            var t = _sessions.ToArray();

            foreach (var member in t)
            {
                member.Dispose();
            }

            // Stop and dispose the timer
            _timer.Stop();
            _timer.Ticked -= Timer_Ticked;
            _timer.Dispose();
        }
        //internal void SendResponseInternal(SipResponse response = null)
        //{
        //    if(response != null) LatestResponse = response;
        //    _provider.SendResponse(LatestResponse);
        //}

        public override void Dispose()
        {
            lock (_lock)
            {
                if (_isDisposed)
                {
                    return;
                }
                _isDisposed = true;
                EndCompletedTimer.Dispose();

                SipAbstractServerTransaction tx;
                if (!_table.TryRemove(this.GetId(), out tx))
                {
                    if (_logger.IsWarnEnabled)
                    {
                        _logger.Warn("The server transaction with id '{0}' could not be removed from the table.");
                    }
                }
            }

            if (_stateObserver != null)
            {
                _stateObserver.OnNext(CreateStateInfo(SipTransactionStateName.Terminated));
                _stateObserver.OnCompleted();
            }
        }
Beispiel #9
0
        /// <inheritdoc/>
        public override Task Connect(grpc.PullConnector request, IServerStreamWriter <grpc.PullRequest> responseStream, ServerCallContext context)
        {
            var id            = request.Id.ToGuid();
            var pullConnector = new PullConnector(id, request.Name, request.Interval);

            ITimer timer = null;

            try
            {
                _pullConnectors.Register(pullConnector);

                timer = _timers.Every(pullConnector.Interval, () =>
                {
                    var pullRequest = new grpc.PullRequest();
                    responseStream.WriteAsync(pullRequest);
                });

                context.CancellationToken.ThrowIfCancellationRequested();
                context.CancellationToken.WaitHandle.WaitOne();
            }
            finally
            {
                timer?.Stop();
                timer?.Dispose();

                _pullConnectors.Unregister(pullConnector);
            }

            return(Task.CompletedTask);
        }
Beispiel #10
0
        public override void Terminate()
        {
            lock (_lock)
            {
                SipAbstractDialog removed;

                if (_logger.IsDebugEnabled)
                {
                    _logger.Debug("Trying to remove ServerDialog[Id={0}] from the table...", GetId());
                }

                if (!_dialogTable.TryRemove(GetId(), out removed))
                {
                    _logger.Warn("Could not remove dialog with id: {0}", GetId());
                }
                else
                {
                    if (_logger.IsDebugEnabled)
                    {
                        _logger.Debug("ServerDialog[Id={0}] removed from table.", GetId());
                    }
                }

                _state = DialogState.Terminated;
            }

            _retransmitOkTimer.Dispose();
            //_endWaitForAckTimer.Dispose();
        }
        private void DisposeNat()
        {
            _logger.Debug("Stopping NAT discovery");

            if (_timer != null)
            {
                _timer.Dispose();
                _timer = null;
            }

            _deviceDiscovery.DeviceDiscovered -= _deviceDiscovery_DeviceDiscovered;

            try
            {
                // This is not a significant improvement
                NatUtility.StopDiscovery();
                NatUtility.DeviceFound -= NatUtility_DeviceFound;
                NatUtility.DeviceLost  -= NatUtility_DeviceLost;
            }
            // 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>
        /// Releases unmanaged and - optionally - managed resources.
        /// </summary>
        /// <param name="disposing"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
        private void Dispose(bool disposing)
        {
            if (m_Disposed)
            {
                return;
            }

            if (disposing)
            {
                try
                {
                    if (m_Timer != null)
                    {
                        m_Timer.Dispose();
                    }

                    if (m_Task != null)
                    {
                        m_Task.Dispose();
                    }
                }
                finally
                {
                    m_Disposed = true;
                }
            }
        }
Beispiel #13
0
        public void Dispose()
        {
            _updateInstantTimer.Dispose();
            _updateConfigurationTimer.Dispose();
            _updateIsPausedTimer.Dispose();

            _enableAfterDelayRegistration?.Dispose();
        }
Beispiel #14
0
 public void Dispose()
 {
     if (_timer != null)
     {
         _timer.Dispose();
         _timer = null;
     }
 }
Beispiel #15
0
 private void DisposeTimer()
 {
     if (_timer != null)
     {
         _timer.Dispose();
         _timer = null;
     }
 }
        protected virtual void Dispose(bool disposing)
        {
            if (disposing)
            {
                timer.Dispose();
            }

            disposed = true;
        }
Beispiel #17
0
        public void Dispose()
        {
            if (_timer is null)
            {
                return;
            }

            _timer.Dispose();
        }
Beispiel #18
0
 /// <summary>
 /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
 /// </summary>
 public void Dispose()
 {
     if (_timer != null)
     {
         _timer.Dispose();
         _timer = null;
     }
     GC.SuppressFinalize(this);
 }
Beispiel #19
0
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         _timer.Dispose();
         _miniMapDelegate.Dispose();
     }
     base.Dispose(disposing);
 }
Beispiel #20
0
        public void TestDisposeTimer()
        {
            WebSocketJetConnection webSocketJetConnection = new WebSocketJetConnection("ws://172.19.191.179:8081");
            ITimer timer = A.Fake <ITimer>();

            webSocketJetConnection.ConnectTimer = timer;
            timer.Enabled = false;
            webSocketJetConnection.Dispose();
            A.CallTo(() => timer.Dispose()).MustHaveHappened(Repeated.Exactly.Once);
        }
        public void Dispose()
        {
            if (this.isDisposed)
            {
                return;
            }

            refreshTimer.Dispose();
            this.isDisposed = true;
        }
Beispiel #22
0
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         if (fTimer != null)
         {
             fTimer.Dispose();
         }
     }
     base.Dispose(disposing);
 }
Beispiel #23
0
 /// <summary>
 /// Dispose of any internal resources
 /// </summary>
 /// <param name="disposing"></param>
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         if (_timer.IsNotNull())
         {
             _timer.Dispose();
         }
     }
     base.Dispose(disposing);
 }
        public void Dispose()
        {
            if (this.isDisposed)
            {
                return;
            }

            refreshTimer.Dispose();
            this.solutionBoundTacker.SolutionBindingChanged -= OnSolutionBoundChanged;
            this.isDisposed = true;
        }
Beispiel #25
0
 public void DisposeBroadcastTimer()
 {
     lock (_timerLock)
     {
         if (_BroadcastTimer != null)
         {
             _BroadcastTimer.Dispose();
             _BroadcastTimer = null;
         }
     }
 }
        public void Dispose()
        {
            if (this.isDisposed)
            {
                return;
            }

            refreshTimer.Dispose();
            initialFetchCancellationTokenSource.Cancel();
            suppressedFileIssues = null;
            this.isDisposed      = true;
        }
        public void Dispose()
        {
            if (this.isDisposed)
            {
                return;
            }

            refreshTimer.Dispose();
            initialFetchCancellationTokenSource.Cancel();
            this.cachedQualityProfiles.Clear();
            this.isDisposed = true;
        }
Beispiel #28
0
        public void Dispose()
        {
            if (_isDisposed)
            {
                return;
            }

            _isDisposed = true;
            Stop();
            _timer.Dispose();
            _logName.LogInfo("Disposed");
        }
Beispiel #29
0
 public void StopAutomaticProgress()
 {
     lock (_progressLock)
     {
         if (_progressTimer != null)
         {
             _progressTimer.Dispose();
             _progressTimer = null;
         }
         _lastProgressInfo = null;
     }
 }
 protected override void Dispose(bool disposing)
 {
     if (!_disposed)
     {
         // someone called Dispose()
         _exerciseTimer.Stop();
         _exerciseTimer.Dispose();
         _timeoutTimer.Stop();
         _timeoutTimer.Dispose();
         _tutorialManager.Dispose();
     }
     base.Dispose(disposing);
 }
Beispiel #31
0
 private void GetRidOfTimer(ITimer timer)
 {
     timer.Elapsed -= timer_Elapsed;
     timer.Stop();
     timer.Dispose();
 }