events and threading

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi there,
i have an object O1 in a thread context C1. This object BeginInvokes() a
loop-oriented method M2 on a second object O2 thereby creating a new thread
context C2 for O2.M2. O1 has before registered on an event eventually fired
by O2.M2. This eventually results in executing the handler function O1.H1 on
thread context C2. This is not thread safe without some provision. Can i
force the execution thread of the handler O1.H1 back to C1 as it is done by
Control.BeginInvoke(). The event firing in O2.M2 is done using some
construction like handler.BeginInvoke() but i suppose this doesnt help.
Thanks for your help
Peter
 
<"Sylvain Lafontaine" <sylvain aei ca (fill the blanks, no spam
please)> said:
I don't know but maybe the following article will help you:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnfo
rms/html/winforms06112002.asp

That article hass an unfortunate bug in, however - it's calling
BeginInvoke on a delegate and never calling EndInvoke, which could lead
to a leak. (Calling Control.BeginInvoke without a matching EndInvoke is
okay though.)

See http://www.pobox.com/~skeet/csharp/threads/threadpool.shtml
for more details of this.
 
Thanks,

I didn't have the occasion to take a look at the multithread
capabilities of DotNet yet - because I'm only working with ASP.NET at the
moment - but surely I will look at this article when I will take the plunge.

S. L.
 
Back
Top