Hi,
Even though there are many examples of Invoke operations, I can't find something that works for me. (I'm using VS 2008, and working in VB)
Here is what i have:
A main module with functions (thread 1) that starts a BeginRead for a TCPClient. When the callback function executes (on thread 3), I want to call a function from the main module, in the main thread. All I get even with Invokes is calling functions that always run in thread 3, not the parent thread.
I call:
MsgBox("Function name: " & Thread.CurrentThread.ManagedThreadId)
in each of my functions do determine on what thread it is executed. At some point, from the infinite read callback function I will have to get a function to show a form, but that function gets caught in the callback thread and freezes, instead of running in the main thread.
Any suggestions ?
Thanks
PS: the callback that I pass to the BeginRead of the TCPClient is a function, not a class, so I can't use raise events.
All I need is to call a function to run in the main thread (main module) from another thread.