Note that there are some explanatory texts on larger screens.

plurals
  1. POParameter count mismatch. - Threading
    primarykey
    data
    text
    <p>I am trying to create a multi-client / server chat small application using WPF but I have some problems. Unfortunately when I press the Connect button the program crashes.</p> <p>Well, I done that so far with the client program(with the thread): <code>public delegate void UpdateText(object txt);</code></p> <p>I got that method:</p> <pre><code> private void UpdateTextBox(object txt) { if (msg_log.Dispatcher.CheckAccess()) { Dispatcher.Invoke(new UpdateText(UpdateTextBox),txt); } else { msg_log.Dispatcher.Invoke(new UpdateText(UpdateTextBox), txt); } } </code></pre> <p>And I am using a Button_Click event to connect to the server like that:</p> <pre><code> private void connect_Click(object sender, RoutedEventArgs e) { if ((nick_name.Text == "") || (ip_addr.Text == "") || (port.Text == "")) { MessageBox.Show("Nick name, IP Address and Port fields cannot be null."); } else { client = new Client(); client.ClientName = nick_name.Text; client.ServerIp = ip_addr.Text; client.ServerPort = port.Text; Thread changer = new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(UpdateTextBox)); changer.Start(); client.OnClientConnected += new OnClientConnectedDelegate(client_OnClientConnected); client.OnClientConnecting += new OnClientConnectingDelegate(client_OnClientConnecting); client.OnClientDisconnected += new OnClientDisconnectedDelegate(client_OnClientDisconnected); client.OnClientError += new OnClientErrorDelegate(client_OnClientError); client.OnClientFileSending += new OnClientFileSendingDelegate(client_OnClientFileSending); client.OnDataReceived += new OnClientReceivedDelegate(client_OnDataReceived); client.Connect(); } } </code></pre> <p>Please note that the OnClient* events are like <code>private void client_OnDataReceived(object Sender, ClientReceivedArguments R) { UpdateTextBox(R.ReceivedData); }</code></p> <p>So these events should write some text like "Connected" into the msg_log TextBox</p> <p>PS. The txt object used to be a string variable but I change it since <code>ParameterizedThreadStart</code> only accepts objects as parameters as I know.</p> <p>Any help would be greatly appreciated!</p> <p>Thanks in advance, George</p> <p>EDIT: Edited the UpdateTextBox method as Abe Heidebrecht suggested.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload