private bool disposedValue = false; // To detect redundant calls protected virtual void Dispose(bool disposing) { if (!disposedValue) { if (disposing) { if (_trace != null) { _trace.OnEvent -= OnTraceEventInternal; _trace?.Drop(); _trace?.Dispose(); _trace = null; } _connection?.Dispose(); _connection = null; _server?.Disconnect(); _server?.Dispose(); _server = null; if (_startingTimer != null) { _startingTimer.Stop(); _startingTimer.Elapsed -= OnTimerElapsed; _startingTimer.Dispose(); _startingTimer = null; } } disposedValue = true; } }
public void Dispose() { if (_trace == null) return; _trace.OnEvent -= OnTraceEventInternal; _trace.Dispose(); _trace = null; }