Wait() and Set()

  • Thread starter Thread starter csharpula csharp
  • Start date Start date
C

csharpula csharp

Hello,
I am using Manual Reset Event by defining it in a thread and than doing
mre.WaitOne(), in the other thread which is activated in a handler which
is called due some event I am doing mre.Set()
But There is no way that the part of mre.Set() i reached although when I
erase the MRE part,the event fires.
How can it be explained?
Thank you!
 
csharpula csharp said:
I am using Manual Reset Event by defining it in a thread and than doing
mre.WaitOne(), in the other thread which is activated in a handler which
is called due some event I am doing mre.Set()
But There is no way that the part of mre.Set() i reached although when I
erase the MRE part,the event fires.
How can it be explained?

Could you post a short but complete program which demonstrates the
problem?

See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.
 
Well,it's more or less this code:

Class A
{
ManualResetEvent mre=new ManualResetEvent();
this.Afunc();
mre.WaitOne();

// Here is a handler to some event which is activated by
// other thread

BHandler(sender,EventArgs args)
{
if (args.counter=1)
{
mre.Set();
}
}
Thank you very much for your help!

}
 
Back
Top