Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 464655
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T23:17:51+00:00 2026-05-12T23:17:51+00:00

Possible duplicate: What is the difference ManualResetEvent and AutoResetEvent in .net? What is the

  • 0

Possible duplicate: What is the difference ManualResetEvent and AutoResetEvent in .net?

What is the difference between ManualResetEvent and AutoResetEvent ? (Example could be helpful).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T23:17:51+00:00Added an answer on May 12, 2026 at 11:17 pm

    ManualResetEvent is like a gate in a field – once it’s been opened, it lets people through until someone shuts it.

    AutoResetEvent is like a turnstile in a train station – once you’ve put the ticket in, one person can go through, but only one.

    Here’s an example – 5 threads are all waiting for the same event, which is set once per second. With a manual reset event, all the threads “go through the gate” as soon as it’s been set once. With an auto-reset event, only one goes at a time.

    using System;
    using System.Threading;
    
    class Test
    {
        static void Main()
        {
            // Change to AutoResetEvent to see different behaviour
            EventWaitHandle waitHandle = new ManualResetEvent(false);
    
            for (int i = 0; i < 5; i++)
            {
                int threadNumber = i;
                new Thread(() => WaitFor(threadNumber, waitHandle)).Start();
            }
            // Wait for all the threads to have started
            Thread.Sleep(500);
    
            // Now release the handle three times, waiting a
            // second between each time
            for (int i = 0; i < 3; i++)
            {
                Console.WriteLine("Main thread setting");
                waitHandle.Set();
                Thread.Sleep(1000);
            }
        }
    
        static void WaitFor(int threadNumber, EventWaitHandle waitHandle)
        {
            Console.WriteLine("Thread {0} waiting", threadNumber);
            waitHandle.WaitOne();
            Console.WriteLine("Thread {0} finished", threadNumber);        
        }
    }
    

    Sample output for ManualResetEvent:

    Thread 0 waiting
    Thread 4 waiting
    Thread 1 waiting
    Thread 2 waiting
    Thread 3 waiting
    Main thread setting
    Thread 2 finished
    Thread 1 finished
    Thread 0 finished
    Thread 4 finished
    Thread 3 finished
    Main thread setting
    Main thread setting
    

    Sample output for AutoResetEvent:

    Thread 0 waiting
    Thread 1 waiting
    Thread 2 waiting
    Thread 3 waiting
    Thread 4 waiting
    Main thread setting
    Thread 3 finished
    Main thread setting
    Thread 2 finished
    Main thread setting
    Thread 1 finished
    

    (The program then just hangs, as there are two threads still waiting for the event to be set, and nothing is going to set it.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Difference between ref and out parameters in .NET What is different between
Possible Duplicate: Difference between ref and out parameters in .NET I know that ref
Possible Duplicate: Difference between <string> and <string.h>? My specific example uses following clause: #include
Possible Duplicate: Difference between .NET 4 Client Profile and Full Framework download I noticed
Possible Duplicate: Difference between a Structure and a Union in C I could understand
Possible Duplicate: Difference between ref and out parameters in .NET When to use ref
Possible Duplicate: Difference between (function(){})(); and function(){}(); I am trying to understand a few
Possible Duplicate: Difference between Color.red and Color.RED I have seen that the Java class
Possible Duplicate: Difference between pointer variable and reference variable in C++ When should I
Possible Duplicate: Difference between pointer variable and reference variable in C++ I am reading

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.