R
Raj
I have .net 3.5 window application having a combobox. While running the
client/server I got this error
Cross-thread operation not valid: Control 'comboBox1' accessed from a thread
other than the thread it was created on.
private void Form1_Load(object sender, EventArgs e)
{
Thread theudpserver = new Thread(new ThreadStart(ServerThread));
theudpserver.Start();
}
public void ServerThread()
{
UdpClient udpclient = new UdpClient(8080);
while (true)
{
IPEndPoint remoteipendpoint = new IPEndPoint(IPAddress.Any,
0);
Byte[] receivebytes = udpclient.Receive(ref remoteipendpoint);
string returndata = Encoding.ASCII.GetString(receivebytes);
comboBox1.Items.Add(remoteipendpoint.Address.ToString() +
":" + returndata.ToString());
}
}
Any help would be appreciated.
Thank you
Regards
Raj
client/server I got this error
Cross-thread operation not valid: Control 'comboBox1' accessed from a thread
other than the thread it was created on.
private void Form1_Load(object sender, EventArgs e)
{
Thread theudpserver = new Thread(new ThreadStart(ServerThread));
theudpserver.Start();
}
public void ServerThread()
{
UdpClient udpclient = new UdpClient(8080);
while (true)
{
IPEndPoint remoteipendpoint = new IPEndPoint(IPAddress.Any,
0);
Byte[] receivebytes = udpclient.Receive(ref remoteipendpoint);
string returndata = Encoding.ASCII.GetString(receivebytes);
comboBox1.Items.Add(remoteipendpoint.Address.ToString() +
":" + returndata.ToString());
}
}
Any help would be appreciated.
Thank you
Regards
Raj