private void Terminate() { _kataFilesMonitor?.Stop(); _playerNotifier?.Dispose(); _updateProcess?.Stop(); _gameMonitor?.Dispose(); _reminderTimer?.Stop(); _monitorTimer?.Stop(); var mainWindow = Current.MainWindow; mainWindow?.Close(); }
private void ExitApplication() { var shutDownActions = new Action[] { () => _kataFilesMonitor?.Stop(), () => _playerNotifier?.Dispose(), () => _gameMonitor?.Dispose(), () => _reminderTimer?.Stop(), () => _monitorTimer?.Stop(), }; var cancellationTokenSource = new CancellationTokenSource(5000); var tasks = shutDownActions .Select(action => Task.Run(() => TryDo(action), cancellationTokenSource.Token)) .ToArray(); Task.WaitAll(tasks); System.Windows.Application.Current.Shutdown(); }