private bool disposedValue = false; // To detect redundant calls protected override void Dispose(bool disposing) { if (!disposedValue) { if (disposing) { UnregisterEvents(); _clock?.Close(); } disposedValue = true; } base.Dispose(disposing); }
private bool disposedValue = false; // To detect redundant calls protected virtual void Dispose(bool disposing) { if (!disposedValue) { if (disposing) { UnregisterEvents(); Stop(); _timer?.Close(); _sound?.Dispose(); } disposedValue = true; } }