private void Connect() { try { Cursor = Cursors.WaitCursor; Task.Run(() => MessagesHubConnection.StartAsync()).GetAwaiter().GetResult(); OutputBuilder.AppendLine("Connected to SignarR Hub"); connectButton.Enabled = false; messageTextBox.Enabled = true; sendButton.Enabled = true; } catch (Exception exception) { OutputBuilder.AppendLine(exception.GetType().ToString()) .AppendLine(exception.Message) .AppendLine(exception.StackTrace) .AppendLine("------------------"); outputTextBox.Text = OutputBuilder.ToString(); } finally { Cursor = Cursors.Default; } }
private void SendCurrentMessage() { MessagesHubConnection.SendAsync("SendToAll", "WinFormClientX", messageTextBox.Text); messageTextBox.Text = String.Empty; }