private void MainForm_FormClosing(object sender, FormClosingEventArgs e) { try { chatService.Disconnect(); } catch (Exception exc) { MessageBoxUtils.ShowException(exc); } }
private async Task InitializeChatService() { try { chatService.OnMessageReceived += AppendMessage; chatService.OnStatusReceived += UpdateStatus; await chatService.Connect(userName); } catch (Exception exc) { MessageBoxUtils.ShowException(exc); } }
private async Task SendMessage() { if (!string.IsNullOrEmpty(tbMessage.Text)) { try { await chatService.SendMessage(userName, tbMessage.Text); tbMessage.Text = string.Empty; tbMessage.Focus(); } catch (Exception exc) { MessageBoxUtils.ShowException(exc); } } }
private async void MainForm_Shown(object sender, EventArgs e) { try { if (GetUserName()) { await InitializeChatService(); } else { Close(); } } catch (Exception exc) { MessageBoxUtils.ShowException(exc); } }
private static void UnhandledExceptionHandler(Exception exception) { MessageBoxUtils.ShowException(exception); }