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; } }
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); } }
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"); } } } }
/// <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); }
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(); } }
/// <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); }
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; } } }
public void Dispose() { _updateInstantTimer.Dispose(); _updateConfigurationTimer.Dispose(); _updateIsPausedTimer.Dispose(); _enableAfterDelayRegistration?.Dispose(); }
public void Dispose() { if (_timer != null) { _timer.Dispose(); _timer = null; } }
private void DisposeTimer() { if (_timer != null) { _timer.Dispose(); _timer = null; } }
protected virtual void Dispose(bool disposing) { if (disposing) { timer.Dispose(); } disposed = true; }
public void Dispose() { if (_timer is null) { return; } _timer.Dispose(); }
/// <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); }
protected override void Dispose(bool disposing) { if (disposing) { _timer.Dispose(); _miniMapDelegate.Dispose(); } base.Dispose(disposing); }
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; }
protected override void Dispose(bool disposing) { if (disposing) { if (fTimer != null) { fTimer.Dispose(); } } base.Dispose(disposing); }
/// <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; }
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; }
public void Dispose() { if (_isDisposed) { return; } _isDisposed = true; Stop(); _timer.Dispose(); _logName.LogInfo("Disposed"); }
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); }
private void GetRidOfTimer(ITimer timer) { timer.Elapsed -= timer_Elapsed; timer.Stop(); timer.Dispose(); }