Using ISynchronizeInvoke

  • Thread starter Thread starter Tim Murray
  • Start date Start date
T

Tim Murray

Hi,
I am creating a multithreaded server application in
Managed C++. Each client that connects to the server will
be running on their own thread to process their input.
They all need to share one instance of a class running on
the main thread. From my understanding, if multiple
threads invoke a function in this object(on the main
thread) using a delegate, there could be problems. I was
trying to figure out how to invoke the functions using
ISynchronizeInvoke, but I have not been able to find a
good example of how to use it. Can anyone point me in the
right direction?

Thanks,
Tim
 
Hi Tim,
I am creating a multithreaded server application in
Managed C++. Each client that connects to the server will
be running on their own thread to process their input.
They all need to share one instance of a class running on
the main thread. From my understanding, if multiple
threads invoke a function in this object(on the main
thread) using a delegate, there could be problems.

There shouldn't be any, as far as I know, as long as the object itself
supports concurrent invocation correctly by ensuring it's own internal state
remains consistent despite being called from multiple threads.

The ISynchronizedInvoke thingie is mostly done to support Winforms, where
calls to UI widgets need to be always done from the same thread, because
they are subject to the old thread-specific issues that plague the win32
user interface event model from the beginning of time.
 
Back
Top