private void StorageServiceButtton_Click(object sender, RoutedEventArgs e) { try { if (StorageServiceHelper.CurrentStatus() != ServiceControllerStatus.Running) { StorageServiceHelper.StartService(startStopComletionCallback); } else { StorageServiceHelper.StopService(startStopComletionCallback); } DisplayCurrentServiceStatus(); } catch (System.Exception ex) { MessageBox.Show(ex.Message); } }
private void Window_Loaded(object sender, RoutedEventArgs e) { if (StorageServiceHelper.IsInstalled() != true) { StorageServiceStateTextBlock.Text = "not installed"; StorageServiceButtton.IsEnabled = false; } else { /*storageServiceStatusCheck = new DispatcherTimer(); * storageServiceStatusCheck.Tick += OnCheckDriveServiceStatus; * storageServiceStatusCheck.Interval = TimeSpan.FromSeconds(10); * storageServiceStatusCheck.Start(); * DisplayCurrentServiceStatus(); * StorageServiceButtton.IsEnabled = true; * if (StorageServiceHelper.CurrentStatus() == ServiceControllerStatus.Running)*/ TryToEstablishPipeConnection(); } }
private void DisplayCurrentServiceStatus() { try { var status = StorageServiceHelper.CurrentStatus(); StorageServiceStateTextBlock.Text = status.ToString(); if (status == ServiceControllerStatus.Stopped) { StorageServiceButtton.Background = notActive; } else { StorageServiceButtton.Background = active; } } catch (System.Exception ex) { MessageBox.Show(ex.Message.ToString()); storageServiceStatusCheck.Stop(); } }