One obvious difference is that a thread would poll to detect a change in a global variable while the wait functions with an event avoid polling. Or, you could use WaitOnAddress but that comes with its own considerations - WaitOnAddress lets you create a synchronization object out of any data variable, even a byte
Global variable vs Events in multi threading

drjackool
956
Reputation points
hi
In Win32 apps (VC++) what is difference between using global variable and events to signal the thread?
What are pros and cons
Thanks
Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,772 questions
Accepted answer
1 additional answer
Sort by: Most helpful
-
Xiaopo Yang - MSFT 12,731 Reputation points Microsoft External Staff
2021-09-14T08:12:15.603+00:00 As far as
WaitOnAddress
andWaitForSingleObject
are concerned, WaitOnAddress is also simpler to use than an event object. But Use caution when calling the wait functions and code that directly or indirectly creates windows.