hi
In Win32 apps (VC++) what is difference between using global variable and events to signal the thread?
What are pros and cons
Thanks
hi
In Win32 apps (VC++) what is difference between using global variable and events to signal the thread?
What are pros and cons
Thanks
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
As far as WaitOnAddress and WaitForSingleObject 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.
11 people are following this question.