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

  • Home
  • SEARCH
  • 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 190939
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T16:17:55+00:00 2026-05-11T16:17:55+00:00

Example System.Threading.AutoResetEvent e = new System.Threading.AutoResetEvent(false); bool b = e.WaitOne(1000, false); I’ve done a

  • 0

Example

System.Threading.AutoResetEvent e = new System.Threading.AutoResetEvent(false);
bool b = e.WaitOne(1000, false);

I’ve done a lot of multi threaded development in my time and have always wondered what the use of the that method was for. The second boolean parameter on the WaitOne is called exitContext. MS Help states
“true to exit the synchronization domain for the context before the wait (if in a synchronized context), and reacquire it afterward; otherwise, false.”

Anyone any idea what this means? Is it something I should be worried about?

Kind Regards
Noel

  • 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-11T16:17:56+00:00Added an answer on May 11, 2026 at 4:17 pm

    I can’t claim credit (hence wiki) but there is a good answer here.

    From the link, answer to the question, by Sasha Goldshtein

    The CLR has support for a notion called contexts. A context is a
    logical grouping of objects. When a method call is made on an object
    that is inside your context, nothing in particular happens except for
    the method itself. When a method call is made on an object that is
    outside your context, then "something" might happen before the method
    itself is executed. All .NET classes derived from ContextBoundObject
    will be associated with a context at runtime.

    An example of that "something" that can happen before the method is
    called would be enforcing synchronization. An object that derives
    from ContextBoundObject and specifies the [Synchronization] attribute
    will get automatic synchronization services from the runtime. This
    means that only one thread will ever be able to execute within the
    object’s context.

    The exitContext parameter of the WaitOne method specifies whether to
    leave the synchronization context before issuing the wait. This
    enables reentrancy. Here’s a scenario where this is necessary:

    Code Snippet

    [Synchronization]
    public class MyCounter : ContextBoundObject {
     
      private int _expectedCounterVal;
      private int _currentCounterVal; 
      private ManualResetEvent _event = new ManualResetEvent(false);
    
      public void WaitUntilCounterIs(int counterVal) {  
        _expectedCounterVal = counterVal;
        _event.WaitOne(TimeSpan.FromDays(1), true);
      }
    
      public void IncrementCounter() {
        if (++_currentCounterVal >= _expectedCounterVal) {    
          _event.Set();
        }
      }
    }
    

    In this case, if the WaitUntilCounterIs method is issued without the
    exitContext=true parameter of the WaitOne method, then no other thread
    will be able to ever call the IncrementCounter method on the object,
    resulting in a deadlock. However, once exitContext=true is specified,
    other threads can enter the IncrementCounter method and signal the
    event at some point, even though the WaitUntilCounterIs method has not
    yet returned.

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

Sidebar

Ask A Question

Stats

  • Questions 91k
  • Answers 91k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Implement INotifyPropertyChanged on your class. If you have many classes… May 11, 2026 at 6:20 pm
  • Editorial Team
    Editorial Team added an answer This is a very common problem. A good approach is… May 11, 2026 at 6:20 pm
  • Editorial Team
    Editorial Team added an answer Use a tool to dump the export table from a… May 11, 2026 at 6:20 pm

Related Questions

If I am using EventWaitHandle (or AutoResetEvent , ManualResetEvent ) to synchronise between threads
Both System.Timers.Timer and System.Threading.Timer fire at intervals that are considerable different from the requested
So is the following equivalent in memory usage? System.Threading.Thread.Sleep(500); vs using System.Threading; ... Thread.Sleep(500);
Is there a way in C# to play audio (for example, MP3) direcly from
I have some ASP.NET page and webservice WebMethod() methods that I'd like to add

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.