How to communicate between threads

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?Q2hyaXN0aWFuIEhhdmVs?=

    How to communicate between threads

    Hi,

    I have one thread thats method is called. When the method is called another
    thread should be notified. How do I do this?

    Christian
  • Marc Gravell

    #2
    Re: How to communicate between threads

    Depends on the scenario... you could use something like a
    ManualResetEven t/AutoResetEvent; you could use a Monitor (Pulse etc). If
    the other thread is a UI thread you could use an event (or a delegate as
    a callback), and then have the UI jump to the UI-thread via
    Control.Invoke/Control.BeginIn voke (or the WPF equivalent); or
    Synchronization Context...

    It really depends what the other thread is doing... in particular, you
    don't want the first thread to *just* spin up the second thread and then
    wait for it to finish - you could just as easily do everything on the
    first thread.

    Marc

    Comment

    • =?Utf-8?B?Q2hyaXN0aWFuIEhhdmVs?=

      #3
      Re: How to communicate between threads

      Hi Marc,

      thanks for your help.

      Christian

      "Marc Gravell" wrote:
      Depends on the scenario... you could use something like a
      ManualResetEven t/AutoResetEvent; you could use a Monitor (Pulse etc). If
      the other thread is a UI thread you could use an event (or a delegate as
      a callback), and then have the UI jump to the UI-thread via
      Control.Invoke/Control.BeginIn voke (or the WPF equivalent); or
      Synchronization Context...
      >
      It really depends what the other thread is doing... in particular, you
      don't want the first thread to *just* spin up the second thread and then
      wait for it to finish - you could just as easily do everything on the
      first thread.
      >
      Marc
      >

      Comment

      • =?UTF-8?B?QmrDuHJuIEJyb3g=?=

        #4
        Re: How to communicate between threads

        Christian Havel skrev:
        Hi,
        >
        I have one thread thats method is called. When the method is called another
        thread should be notified. How do I do this?
        >
        Christian


        --
        Bjørn Brox

        Comment

        • =?Utf-8?B?Q2hyaXN0aWFuIEhhdmVs?=

          #5
          Re: How to communicate between threads

          Hi Bjørn,

          thanks for your help!

          Christian

          "Bjørn Brox" wrote:
          Christian Havel skrev:
          Hi,

          I have one thread thats method is called. When the method is called another
          thread should be notified. How do I do this?

          Christian
          >

          >
          --
          Bjørn Brox
          >

          Comment

          Working...