difference between Autoreset event and Manualreset event with exapmle [Resolved]

Posted by krrishbiju-15589 under C# on 9/3/2013 | Points: 10 | Views : 1673 | Status : [Member] | Replies : 3
HI,
Anyone please explain about difference between Autoreset event and Manualreset event with exapmle.
regards
krrish




Responses

Posted by: Allemahesh on: 9/3/2013 [Member] [MVP] Silver | Points: 50

Up
0
Down

Resolved
"AutoResetEvent" and "ManualResetEvent" are threading concepts which help us to manage synchronization using events/ signals. For instance let's say you have two threads as shown in the figure http://www.dotnetinterviewquestions.in/contentpics/auto1.jpg . So by using these two concepts you can make one thread wait and when the other thread finishes processing he can signal the second thread to start from where he has halted.

Below are some differents:-

1. An AutoResetEvent resets when the code passes through event.WaitOne(), but a ManualResetEvent does not. This means that It's like the difference between a tollbooth and a door. The ManualResetEvent is the door, which needs to be closed (reset). The AutoResetEvent is a tollbooth, allowing one car to go by and automatically closing before the next one can get through.
2. When we use "AutoResetEvent" for every wait one we need a "Set" to revoke. In "ManualResetEvent" once we can the "Set" , all "WaitOne" will execute until we call "Close".
You can see the http://www.dotnetinterviewquestions.in/contentpics/auto2.jpg Image.

Others Links:-
http://www.codeproject.com/Articles/39040/Auto-and-Manual-Reset-Events-Revisited
http://social.msdn.microsoft.com/Forums/vstudio/en-US/1e86a2cc-34d0-48a4-8381-8ed6e99a045b/when-and-why-would-one-use-the-autoresetevent-over-manualresetevent

Happy Coding.

krrishbiju-15589, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Bandi on: 9/3/2013 [Member] [MVP] Platinum | Points: 25

Up
0
Down
Refer "Signaling with Event Wait Handles" section in the link http://www.albahari.com/threading/part2.aspx

Mark This Response as Answer
--
Chandu
http://www.dotnetfunda.com/images/dnfmvp.gif

krrishbiju-15589, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: krrishbiju-15589 on: 9/3/2013 [Member] Starter | Points: 25

Up
0
Down
Thanks Allemahesh,
This one is helpful....

krrishbiju-15589, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response