© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•2y ago
Tony Wang

Monitor Signaling

I have some code where someone used the Monitor Class to signal between two threads. It looks very similar to the code in the top reply in:

https://stackoverflow.com/questions/1355398/monitor-vs-waithandle-based-thread-sync

I am planning to convert the code using EventWaitHandle instead, but I want to understand the solution first and I have troubles understanding why they used "while (!signalSet)" instead of "if(!signalSet)". Is there a difference in that case? if yes, what is the difference and if no, is there any reason to write while?
Stack Overflow
Monitor vs WaitHandle based thread sync
I was under the impression, after reading this article that it is better to use Monitor/Lock for thread synchronisation as it does not use native resources
Specific quote (from page 5 of the articl...
Monitor vs WaitHandle based thread sync
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Thread signaling still the best practice?
C#CC# / help
3y ago
Synchronizing with Monitor
C#CC# / help
2y ago
All Monitor ScreenShot
C#CC# / help
2y ago
App Insights vs Azure Monitor (OpenTelemetry)
C#CC# / help
17mo ago