Esempio n. 1
0
        private void connectButton_Click(object sender, RoutedEventArgs e)
        {
            ProtoClient.OnHandshakeReceived += ProtoClient_OnHandshakeReceived;
            connectButton.IsEnabled          = false;
            Task.Factory.StartNew((o) =>
            {
                string[] array = (string[])o;
                string server  = array[0];
                string nick    = array[1];

                try
                {
                    ProtoClient.Connect(server);
                    ProtoClient.SendHandshake(ProtoClient.VERSION, nick);
                }
                catch
                {
                    this.Invoke(() =>
                    {
                        MessageBox.Show(this.GetMainWindow(), $"Could not establish connection with {this.serverTextBox.Text}");
                        connectButton.IsEnabled = true;
                    });
                }
            }, new string[] { this.serverTextBox.Text, this.nickTextBox.Text });
        }