public MainWindowViewModel() { ServiceModel = new WindowsServiceSettingsModel(); ClientModel = new WindowsClientSettingsModel(); StartServiceCommand = new DelegateCommand(async() => await StartServiceAsync()); StopServiceCommand = new DelegateCommand(async() => await StopServiceAsync()); UpdateSettingsCommand = new DelegateCommand(async() => await ServiceModel.UpdateServiceSettingsAsync()); ConnectClientCommand = new DelegateCommand(async() => await ClientModel.ConnectClientAsync()); SelectFileToUploadCommand = new DelegateCommand(async() => await UploadFilesAsync()); // Check the status of the service every second. Observable.Interval(TimeSpan.FromSeconds(1)) .Subscribe(async _ => await GetServiceStatusAsync()); }
private async Task GetServiceStatusAsync() { Status = await WindowsServiceSettingsModel.GetServiceStatus(); }
private async Task StartServiceAsync() { await WindowsServiceSettingsModel.InitializeClientAsync(); await GetServiceStatusAsync(); }
private async Task StopServiceAsync() { await WindowsServiceSettingsModel.StopClientAsync(); await GetServiceStatusAsync(); }