question

drjackool-3839 avatar image
0 Votes"
drjackool-3839 asked XiaopoYang-MSFT answered

Global variable vs Events in multi threading

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
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

RLWA32-6355 avatar image
1 Vote"
RLWA32-6355 answered

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


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

XiaopoYang-MSFT avatar image
0 Votes"
XiaopoYang-MSFT answered
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.