public MainWindow(ClientSettingsDto settings) { InitializeComponent(); status = SBClientStatuses.WaitingForFile; // Неплохое решение насчет передачи Экшена UpdateProgress для апдейта прогрес-бара, // однако я бы лучше сделал подписку на событие, потому что тогда SBClientManager делает слишком много вещей. _messageClient = new SBClientManager(settings, new ConsoleLogger(), "MyClient1"); _messageClient.FilePartSentNotify += UpdateProgress; mainTimer = new Timer(CheckServerStatus); mainTimer.Change(0, settings.StatusSendPeriodMs); _brokerMessageSender = new BrokerMessageSender(_messageClient); }
private void Button_Click(object sender, RoutedEventArgs e) { UploadProgress.Value = 0; status = SBClientStatuses.UploadingFile; var dlg = new CommonOpenFileDialog(); dlg.Title = "Select file to send"; dlg.IsFolderPicker = false; if (dlg.ShowDialog() == CommonFileDialogResult.Ok) { _brokerMessageSender .SendFile(dlg.FileName) .ContinueWith((t) => FinishSend()); } }
private void FinishSend() { Dispatcher.Invoke(() => UploadProgress.Value += UploadProgress.Maximum); MessageBox.Show($"File was sent successfully!"); status = SBClientStatuses.WaitingForFile; }
public void SendClientStatus(SBClientStatuses status) { _queueClientStatusClient.Send(new BrokeredMessage($"{DateTime.Now}: Client {_clientName} has status {status}")); }