C# Programming
08-13-2009, 11:56 AM
Hi all,
I am busy developing a custom TCP/IP server. The server has a few events namely, NewTcpData, NewTcpClient and TcpClientDisconnected. At the moment I just want to know of these events.
So I have created the events and all is working fine, but as soon as I call the event from my GUI app, I receive a message stating: Cross-thread operation not valid ...
So normally I would hook the GUI control to the SynchronizationContext.
For example:
context.Send(new SendOrPostCallback((s) => this.textBox1.Text = "Some Data"), null);
So, my question: how can I develop / alter the event(s) (which runs on a separate thread that the main) to not make use of the above technique, and still be able to send / set data to the GUI controls?
Many thanks in advance.
Kind regards,
The only programmers that are better C# programmers, are those who look like this -> http://www.barakasoft.com/script/Forums/Images/alien.gif
http://www.barakasoft.com/script/Forums/Images/smiley_smile.gifProgramm3r
My Blog: ^_^ (http://www.codeproject.com/script/profile/whos_who.asp?msg=1917620&id=2823228#xx1917620xx)
I am busy developing a custom TCP/IP server. The server has a few events namely, NewTcpData, NewTcpClient and TcpClientDisconnected. At the moment I just want to know of these events.
So I have created the events and all is working fine, but as soon as I call the event from my GUI app, I receive a message stating: Cross-thread operation not valid ...
So normally I would hook the GUI control to the SynchronizationContext.
For example:
context.Send(new SendOrPostCallback((s) => this.textBox1.Text = "Some Data"), null);
So, my question: how can I develop / alter the event(s) (which runs on a separate thread that the main) to not make use of the above technique, and still be able to send / set data to the GUI controls?
Many thanks in advance.
Kind regards,
The only programmers that are better C# programmers, are those who look like this -> http://www.barakasoft.com/script/Forums/Images/alien.gif
http://www.barakasoft.com/script/Forums/Images/smiley_smile.gifProgramm3r
My Blog: ^_^ (http://www.codeproject.com/script/profile/whos_who.asp?msg=1917620&id=2823228#xx1917620xx)