Have your Client class inherit Control. Then, in your Client class, you can
use Me.Invoke to marshal back to the main thread before you raise your
event. Then the event handler in your form will be running on the correct
thread. I used this technique here:
http://msdn.microsoft.com/library/de...dunplugged.asp
Also, VS 2005 will solve this with a "BackgroundWorker" control. Juval has
written an implementation of that control that you can use today with VS
2003:
http://www.devx.com/codemag/Article/...k=DXRSS_DOTNET
(free, but registration required)
--
Scott Swigart
http://blog.swigartconsulting.com
"Joe Wright" <jo********@noventech.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Hello, I have a client/server application that needs to show forms
depending on what is received. The problem is that my Client class that
handles all of the sending and receiving of data raises it's DataReceived
event in the thread that is asyncronously reading the data from the
tcpclient. This means that I can't create any controls on my main form in
the DataReceived event. Does anyone know how I can raise the event in the
main thread. Any help would be appreciated. Thanks.
Joe