Multicast delegates with thread synchronization?

  • Thread starter Thread starter Christoph Nahr
  • Start date Start date
C

Christoph Nahr

The task: I want to let a background thread and a Windows Forms
foreground thread communicate via callback methods.

Now synchronization of a *single* delegate works just fine with the
usual Control.Invoke or Control.BeginInvoke methods.

However, I couldn't find any information on using this technique with
multicast delegates, i.e. the magic thingie created by the "event"
keyword in C#.

Is it possible to marshal calls on multicast delegates to another
thread? Perhaps even one specific target thread for each individual
delegate? If so, how would I go about it?
 
Its not particularly clear what you are asking. All background threads can
only communicate with UI components through the controls Invoke, BeginInvoke,
EndInvoke and CreateGraphics methods.

A multicast delegate is just a linked list of delegates, each of which will
be called in turn. Which means you need to ensure the UI calls this delegate
in the UI thread if it is a UI method.

Maybe if you post some code that demonstrates your problem, that would make
things a little clearer.

Dan
 
Back
Top