public void Dispose() { if (IsVisible) { Close(); } try { _cancellationSource.Cancel(); } catch (ObjectDisposedException) { } }