// JP opened flex table

Click to See Complete Forum and Search --> : mfc/console thread imp.


hkullana
July 3rd, 2007, 07:05 AM
hi,

when i compile the below code in mfc:

CWinThread *thread;

thread = AfxBeginThread(thethread,this);

it is working nice.

But when i compile it in the console the thread function works only one time.

It needs the below line at the end:

WaitForSingleObject(GetCurrentThread(), INFINITE);

Why there such a difference ?

Bornish
July 3rd, 2007, 07:57 AM
A console application terminates after the main function exists... since is not "designed" as a GUI interface (only UI). The MFC application has an "already implemented" main function which waits for the GUI to terminate the main thread... meaning the "while getmessage" loop is already implemented for the main thread (GUI thread).
Hmm, my post doesn't sound very clear... :o ... but I hope gives the necessary hint in looking for the behavioural differences between the 2.
Regards,

hkullana
July 3rd, 2007, 10:07 AM
o thanks i got the point

//JP added flex table