Using ISynchronizeInvoke

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Tim Murray

    #1

    Using ISynchronizeInvoke

    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
    ISynchronizeInv oke, 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
  • Tomas Restrepo \(MVP\)

    #2
    Re: Using ISynchronizeInv oke

    Hi Tim,
    [color=blue]
    > 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.[/color]

    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 ISynchronizedIn voke 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.

    --
    Tomas Restrepo
    tomasr@mvps.org


    Comment

    Working...