Wait() and Set()

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!
 
J

Jon Skeet [C# MVP]

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.
 
C

csharpula csharp

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!

}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top