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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T20:43:20+00:00 2026-05-13T20:43:20+00:00

While reading C# 3.0 in a Nutshell by Joseph and Ben Albahari , I

  • 0

While reading C# 3.0 in a Nutshell by Joseph and Ben Albahari, I came across the following paragraph (page 673, first paragraph in section titled “Signaling with Wait and Pulse“)

“The Monitor class provides another signalling construct via two static methods, Wait and Pulse. The principle is that you write the signalling logic yourself using custom flags and fields (enclosed in lock statements), and then introduce Wait and Pulse commands to mitigate CPU spinning. The advantage of this low-level approach is that with just Wait, Pulse, and the lock statement, you can achieve the functionality of AutoResetEvent, ManualResetEvent, and Semaphore, as well as WaitHandle‘s static methods WaitAll and WaitAny. Furthermore, Wait and Pulse
can be amenable in situations where
all of the wait handles are
parsimoniously challenged.”

My question is, what is the correct interpretation of the last sentence?

  • A situation with a decent/large number of wait handles where WaitOne() is only occasionally called on any particular wait handle.
  • A situation with a decent/large number of wait handles where rarely does more than one thread tend to block on any particular wait handle.
  • Some other interpretation.

Would also appreciate illuminating examples of such situations and perhaps how and/or why they are more efficiently handled via Wait and Pulse rather than by other methods.

Thank you!

Edit: I found the text online here

  • 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-13T20:43:20+00:00Added an answer on May 13, 2026 at 8:43 pm

    What this is saying is that there are some situations where Wait and Pulse provides a simpler solution than wait handles. In general, this happens where:

    • The waiter, rather than the notifier, decides when to unblock
    • The blocking condition involves more than a simple flag (perhaps several variables)

    You can still use wait handles in these situations, but Wait/Pulse tends to be simpler. The great thing about Wait/Pulse is that Wait releases the underlying lock while waiting. For instance, in the following example, we’re reading _x and _y within the safety of a lock – and yet that lock is released while waiting so that another thread can update those variables:

    lock (_locker)
    {
      while (_x < 10 && _y < 20) Monitor.Wait (_locker);
    }
    

    Another thread can then update _x and _y atomically (by virtue of the lock) and then Pulse to signal the waiter:

    lock (_locker)
    {
      _x = 20;
      _y = 30;
      Monitor.Pulse (_locker);
    } 
    

    The disadvantage of Wait/Pulse is that it’s easier to get it wrong and make a mistake (for instance, by updating a variable and forgetting to Pulse). In situations where a program with wait handles is equally simple to a program with Wait/Pulse, I’d recommend going with wait handles for that reason.

    In terms of efficiency/resource consumption (which I think you were alluding to), Wait/Pulse is usually faster and lighter (as it has a managed implementation). This is rarely a big deal in practice, though. And on that point, Framework 4.0 includes low-overhead managed versions of ManualResetEvent and Semaphore (ManualResetEventSlim and SemaphoreSlim).

    Framework 4.0 also provides many more synchronization options that lessen the need for Wait/Pulse:

    • CountdownEvent
    • Barrier
    • PLINQ / Data Parallelism (AsParallel, Parallel.Invoke, Parallel.For, Parallel.ForEach)
    • Tasks and continuations

    All of these are much higher-level than Wait/Pulse and IMO are preferable for writing reliable and maintainable code (assuming they’ll solve the task at hand).

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

Sidebar

Related Questions

While reading Joe Albahari's excellent book Threading in C# I came across the following
i have came across the sentence in a nutshell while reading a technical book
While reading the Hashing topic of C# in a nutshell book,i came across the
While reading Jack Shirazi's 'Java performance tuning', I came across the following statement: Instance
While reading Python scripting for computational science I came across the following text in
I came across the following while reading about how easy it is to redefine
I was reading C# 4.0 in a Nutshell by Joseph and Ben Albahari and
While reading Bruce Eckel i came across the following example: #include <cstdio> #include <cstdlib>
While reading the Clang documentation, I came across the following intriguing tidbit: [1] clang
While reading up on POSIX threading, I came across an example of thread-specific-data. I

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.