<email@example.com> wrote in message
in my program main thread needs to know,so i should use postmessage,
but i would like to know what is the advantage over direct global
The advantage of using a messaage is that your program will be event-driven.
You don't have to poll or use a timer to check. You get notified
immediately when the file loading finishes, with no extra code or variables
or execution. The main thread is event-driven, so the simplest and best
architectural solution is to use a message when you want the main thread to
anyway i have to use member variable
because i have to check in timer call back(file loading finish or
not),here i will get message on message procedure, should i set
variable(like m_fileOpened).,why i cannot set global variable in
worker thread instead of that ?any chance to get serious issue?..
please don't misunderstand my words, i am eager to learn more..that is
why i am writing this.
You *could* use a member variable, or a global variable. These just use
more steps and resources to get the job done more awkwardly. And, in cases
where you need to pass anything more complex that a bool you have to add
more complexity for interthread synchronization of shared data.
Scott McPhillips [VC++ MVP]