/// <summary> /// Stops listening for client connections /// </summary> public void Stop() { _mreIsListening?.Dispose(); _mreIsListening = null; _host?.Stop(); _host = null; }
public void Dispose() { if (_isDisposed) { return; } SpiComm?.Dispose(); _spiCommController?.Dispose(); Pins.Reset?.Dispose(); if (Pins.Dio0 != null) { Pins.Dio0.ValueChanged -= Dio0Pin_ValueChanged; Pins.Dio0.Dispose(); } Pins.Dio1?.Dispose(); Pins.Dio2?.Dispose(); Pins.Dio3?.Dispose(); Pins.Dio4?.Dispose(); Pins.Dio5?.Dispose(); _transmissionCompletedEventSlim?.Dispose(); _isDisposed = true; }
private void ResetConnections() { _queue.DispatchAsync(() => { _client?.Dispose(); _client = null; NetworkStream?.Dispose(); NetworkStream = null; _readWriteCancellationTokenSource?.Cancel(); _readWriteCancellationTokenSource?.Dispose(); _readWriteCancellationTokenSource = null; _receivePause?.Dispose(); _receivePause = null; _writeQueue?.CompleteAdding(); var count = 0; while (count++ < 5 && _writeQueue != null && !_writeQueue.IsCompleted) { Thread.Sleep(500); } if (_writeQueue != null && !_writeQueue.IsCompleted) { Log.To.Sync.W(Tag, "Timed out waiting for _writeQueue to finish, forcing Dispose..."); } _writeQueue?.Dispose(); _writeQueue = null; }); }
public override void Dispose() { _leaderEvent?.Dispose(); _leaderEvent = null; base.Dispose(); }
public void Dispose() { _cacheRenewCts.Cancel(); _cacheRenewMre.Set(); _cacheRenewMre?.Dispose(); _cacheRenewCts?.Dispose(); }
/// <summary> /// Performs application-defined tasks associated with freeing, releasing, or resetting /// unmanaged resources. /// </summary> public void Dispose() { _intializedEvent?.Dispose(); _collection?.Dispose(); GC.SuppressFinalize(this); }
/// <summary>Performs a blocking WaitAll on the vetted list of tasks.</summary> /// <param name="tasks">The tasks, which have already been checked and filtered for completion.</param> /// <param name="millisecondsTimeout">The timeout.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <returns>true if all of the tasks completed; otherwise, false.</returns> private static bool WaitAllBlockingCore(List <Task> tasks, int millisecondsTimeout, CancellationToken cancellationToken) { if (tasks == null) { Contract.Assert(false, "Expected a non-null list of tasks"); throw new ArgumentNullException(nameof(tasks)); } Contract.Assert(tasks.Count > 0, "Expected at least one task"); bool waitCompleted; ManualResetEventSlim?manualResetEventSlim = null; WhenAllCore? core = null; try { manualResetEventSlim = new ManualResetEventSlim(false); core = new WhenAllCore(tasks, manualResetEventSlim.Set); waitCompleted = core.IsDone || manualResetEventSlim.Wait(millisecondsTimeout, cancellationToken); } finally { if (core != null) { core.Dispose(); waitCompleted = core.IsDone; } manualResetEventSlim?.Dispose(); } return(waitCompleted); }
//private Lockable<bool> IsDisposed { get; } = new Lockable<bool>(); /// <summary>Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.</summary> protected virtual void OnDispose() { _mreWriteComplete?.Dispose(); _mreWriteComplete = null; _thread?.Dispose(); _thread = null; }
public void Dispose() { _webJobsShutdownWatcher?.Dispose(); _shutdownHandle?.Dispose(); _linkedCts?.Dispose(); _internalCts?.Dispose(); _waitForExit?.Dispose(); }
protected virtual void Dispose(bool disposing) { if (disposing) { _finalEventRaised?.Dispose(); _isolatedContext?.Dispose(); } }
// IDisposable //////////////////////////////////////////////////////////////////////////// public void Dispose() { if (!_disposed) { _disposed = true; _workingMres?.Dispose(); } }
/// <summary> /// Releases unmanaged and - optionally - managed resources. /// </summary> /// <param name="alsoManaged"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param> private void Dispose(bool alsoManaged) { if (IsDisposed) return; IsDisposed = true; Event?.Set(); Event?.Dispose(); Event = null; }
public virtual void Dispose() { if (online) { StopListener(); } acceptEvent?.Dispose(); timeoutEvent?.Dispose(); }
public void Dispose() { _connectedEvent?.Dispose(); _navigationCompleted?.Dispose(); _dispatcherJobs?.Dispose(); _mediatorTaskCTSource?.Dispose(); _outputBlocked?.Dispose(); _outputBlockedBuffer?.Dispose(); }
// IDisposable //////////////////////////////////////////////////////////////////////////// public void Dispose() { if (!_disposed) { _disposed = true; _workingMres?.Dispose(); _tcpListener?.Stop(); } }
public void Dispose() { FreeBlocksSyncAllocation(); _syncTimer?.Dispose(); _syncLoopTask?.Dispose(); _syncLoopCancellation?.Dispose(); _peerSyncCancellation?.Dispose(); _syncRequested?.Dispose(); }
// IDisposable //////////////////////////////////////////////////////////////////////////// public void Dispose() { if (!_disposed) { _disposed = true; _bufferedClient?.Dispose(); _connectedMres?.Dispose(); } }
public void Dispose() { if (_disposed) { return; } _disposed = true; _resetEvent?.Dispose(); }
public void Dispose() { if (_disposed) { return; } _disposed = true; _cancellationTokenSource.Cancel(); _resetEventSlim?.Dispose(); }
/// <inheritdoc /> void IDisposable.Dispose() { if (IsDisposed) { return; } IsDisposed = true; _event?.Set(); _event?.Dispose(); _event = null; }
/// <inheritdoc /> public void Dispose() { if (IsDisposed) { return; } IsDisposed = true; _event?.Set(); _event?.Dispose(); _event = null; }
public virtual void Dispose() { if (online) { StopListener(); } listener?.Dispose(); listener = null; sender?.Dispose(); sender = null; receiveEvent?.Dispose(); }
protected virtual void Dispose(bool disposing) { if (!_disposed) { if (disposing) { _sender?.Dispose(); _pingComplete?.Dispose(); } _disposed = true; } }
public void Dispose() { if (_cmdlet != null) { _cmdlet.CommandRuntime = _originalCommandRuntime; _cmdlet = null; } _semaphore?.Dispose(); _semaphore = null; _readyToRun?.Dispose(); _readyToRun = null; _completed?.Dispose(); _completed = null; }
public void Dispose() { if (cmdlet != null) { cmdlet.CommandRuntime = this.originalCommandRuntime; cmdlet = null; } semaphore?.Dispose(); semaphore = null; readyToRun?.Dispose(); readyToRun = null; completed?.Dispose(); completed = null; }
protected virtual void Dispose(bool disposing) { if (_disposed) { return; } if (disposing) { _innerResetEventSlim?.Dispose(); _cancellationTokenSource?.Dispose(); } _disposed = true; }
public void Successful_AppObserver_Run_Cancellation_Via_ObserverManager() { ObserverManager.FabricServiceContext = this.context; ObserverManager.TelemetryEnabled = false; ObserverManager.EtwEnabled = false; ObserverManager.FabricClientInstance = new FabricClient(FabricClientRole.User); var stopWatch = new Stopwatch(); var obs = new AppObserver { IsEnabled = true, NodeName = "_Test_0", IsTestRun = true, }; var obsMgr = new ObserverManager(obs) { ApplicationName = "fabric:/TestApp0", }; var objReady = new ManualResetEventSlim(false); stopWatch.Start(); var t = Task.Factory.StartNew(() => { objReady.Set(); obsMgr.StartObservers(); }); objReady?.Wait(); while (!obsMgr.IsObserverRunning && stopWatch.Elapsed.TotalSeconds < 10) { // wait... } stopWatch.Stop(); // Observer is running. Stop it... obsMgr.StopObservers(); Thread.Sleep(5); Assert.IsFalse(obsMgr.IsObserverRunning); obs.Dispose(); objReady?.Dispose(); }
/// <inheritdoc /> /// <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> protected override void Dispose(bool disposing) { if (!IsDisposed) { if (disposing) { _allDone?.Dispose( ); _isListening = false; } _listener?.Close( ); } IsDisposed = true; base.Dispose(disposing); }
/// <inheritdoc /> public void Dispose() { if (!_disposed) { _disposeToken.Cancel(); if (!_transmissionStopped) { _resetEvent.Wait(TimeSpan.FromSeconds(5)); } _disposeToken?.Dispose(); _resetEvent?.Dispose(); _disposed = true; } }
public void Dispose() { try { tokenSource?.Cancel(); waitEvent.Set(); } catch { } foreach (var packetSource in packetSourceList) { packetSource.Dispose(); } packetSourceList.Clear(); tokenSource?.Dispose(); waitEvent?.Dispose(); }
public static void CancelBeforeWait() { ManualResetEventSlim mres = new ManualResetEventSlim(); CancellationTokenSource cs = new CancellationTokenSource(); cs.Cancel(); CancellationToken ct = cs.Token; const int millisec = 100; TimeSpan timeSpan = new TimeSpan(100); EnsureOperationCanceledExceptionThrown( () => mres.Wait(ct), ct, "CancelBeforeWait: An OCE should have been thrown."); EnsureOperationCanceledExceptionThrown( () => mres.Wait(millisec, ct), ct, "CancelBeforeWait: An OCE should have been thrown."); EnsureOperationCanceledExceptionThrown( () => mres.Wait(timeSpan, ct), ct, "CancelBeforeWait: An OCE should have been thrown."); mres.Dispose(); }
public static void RunManualResetEventSlimTest5_Dispose() { ManualResetEventSlim mres = new ManualResetEventSlim(false); mres.Dispose(); }
public static void RunManualResetEventSlimTest5_Dispose() { ManualResetEventSlim mres = new ManualResetEventSlim(false); try { mres.Dispose(); } catch { Assert.True(false, string.Format("RunManualResetEventSlimTest5_Dispose: FAILED. Calling Dispose on a disposed MRES shouldn't throw")); } }
public static void RunManualResetEventSlimTest5_Dispose_Negative() { ManualResetEventSlim mres = new ManualResetEventSlim(false); mres.Dispose(); Assert.Throws<ObjectDisposedException>(() => mres.Reset()); // Failure Case: The object has been disposed, should throw ObjectDisposedException. Assert.Throws<ObjectDisposedException>(() => mres.Wait(0)); // Failure Case: The object has been disposed, should throw ObjectDisposedException. Assert.Throws<ObjectDisposedException>( () => { WaitHandle handle = mres.WaitHandle; }); // Failure Case: The object has been disposed, should throw ObjectDisposedException. mres = new ManualResetEventSlim(false); ManualResetEvent mre = (ManualResetEvent)mres.WaitHandle; mres.Dispose(); Assert.Throws<ObjectDisposedException>(() => mre.WaitOne(0)); // Failure Case: The underlying event object has been disposed, should throw ObjectDisposedException. }