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 3798222
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T13:32:15+00:00 2026-05-19T13:32:15+00:00

i am little confused about the manual reset event’s wait one method , consider

  • 0

i am little confused about the manual reset event’s wait one method , consider below scenarion

static  object objLock = new object();

    static int counter = 5;

    static ManualResetEvent mEvent = new ManualResetEvent(false);

    static void Main(string[] args)
    {
        ///LeftShifting(10, 4);

       // RightShifting(3, 1);

       // Xoring(0001, 1001);

       // ExcahnageValuesWithXoring(10, 20);

       // ReverseBits(0);

        Thread.CurrentThread.Name = "Main Thread";

        for(int i=0;i<5;i++)
        {
            Thread t = new Thread(new ThreadStart(DoSomeLongWork));
            t.Name = i.ToString();
            t.Start();
        }

        Console.WriteLine("Current thread is " + Thread.CurrentThread.Name);

        mEvent.WaitOne();

        Console.WriteLine("Current thread is " + Thread.CurrentThread.Name);
        Console.WriteLine("Completed Long Running Process...");
        Console.ReadLine();
    }

    private static void DoSomeLongWork()
    {

        Console.WriteLine("Starting Long Running Process...On " + Thread.CurrentThread.Name);

        Thread.Sleep(5000);

        Interlocked.Decrement(ref counter);

        Console.WriteLine("Ending Long Running Process...On " + Thread.CurrentThread.Name);

        if (counter == 0)
            mEvent.Set();

    }

my question is when i call mEvent.Waitone() is it going to block ‘Main Thread’ or the one of the executing child thread.

  • 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-19T13:32:16+00:00Added an answer on May 19, 2026 at 1:32 pm

    It blocks the main thread. That’s the only one it can block. You can’t force another thread to sleep. The main thread will wait for the other thread to “set” the event. This is very much like Monitor.Wait/Pulse.

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

Sidebar

Related Questions

I'm a little bit confused about Git. When I'm looking through the manual it
I'm a little confused about how the standard library will behave now that Python
I'm a little confused about HTML classes and IDs, as I'd like to use
Still a little confused about Objective-C memory management. I think my confusion stems from
I am a little confused about two new technologies receiving a lot of buzz
I'm a little confused about when exactly my Property is being initialized. Suppose I
I'm a little confused about CSS and the class attribute. I always thought, the
I'm a little confused about the Swing painting model. Suppose that I have a
I'm a little confused about the granularity offered by the HttpResponse.RemoveOutputCacheItem() call. I'm interested
I am a little confused about the session management in PHP. A lot of

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.