Click here to Skip to main content
15,893,622 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Questionwait for CWinThread to terminate -- from UI thread Pin
Peter Weyzen24-Oct-07 9:27
Peter Weyzen24-Oct-07 9:27 
AnswerRe: wait for CWinThread to terminate -- from UI thread Pin
Peter Weyzen24-Oct-07 9:43
Peter Weyzen24-Oct-07 9:43 
AnswerRe: wait for CWinThread to terminate -- from UI thread Pin
pierre_ribery24-Oct-07 10:45
pierre_ribery24-Oct-07 10:45 
AnswerRe: wait for CWinThread to terminate -- from UI thread Pin
JudyL_MD24-Oct-07 10:51
JudyL_MD24-Oct-07 10:51 
GeneralRe: wait for CWinThread to terminate -- from UI thread Pin
pierre_ribery24-Oct-07 10:59
pierre_ribery24-Oct-07 10:59 
GeneralRe: wait for CWinThread to terminate -- from UI thread Pin
JudyL_MD24-Oct-07 11:09
JudyL_MD24-Oct-07 11:09 
GeneralRe: wait for CWinThread to terminate -- from UI thread Pin
Peter Weyzen24-Oct-07 11:18
Peter Weyzen24-Oct-07 11:18 
AnswerRe: wait for CWinThread to terminate -- from UI thread Pin
Mark Salsbery24-Oct-07 12:18
Mark Salsbery24-Oct-07 12:18 
Are you terminating a UI thread from within itself as you're showing
in your code or do you want to terminate a thread from another
thread and wait?

For the latter, maybe something like this:
// Called on main thread to terminate OtherCWinThread (a CWinThread object, UI thread)

OtherCWinThread.PostThreadMessage(WM_QUIT, 0, 0);

while (1)
{
    DWORD dwWaitRet = ::MsgWaitForMultipleObjects(1, &OtherCWinThread.m_hThread, FALSE, INFINITE, QS_ALLEVENTS);

    if (dwWaitRet != WAIT_OBJECT_0 + 1)
        break;

    MSG msg;
    while ( ::PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)) 
    { 
        AfxGetApp()-> PumpMessage(); 
    } 
}

mark



Mark Salsbery
Microsoft MVP - Visual C++

Java | [Coffee]

GeneralRe: wait for CWinThread to terminate -- from UI thread Pin
Peter Weyzen24-Oct-07 13:31
Peter Weyzen24-Oct-07 13:31 
GeneralRe: wait for CWinThread to terminate -- from UI thread Pin
Peter Weyzen31-Oct-07 17:49
Peter Weyzen31-Oct-07 17:49 
QuestionProblem!!! Pin
purplee8524-Oct-07 7:00
purplee8524-Oct-07 7:00 
AnswerRe: Problem!!! Pin
led mike24-Oct-07 7:23
led mike24-Oct-07 7:23 
QuestionRe: Problem!!! Pin
David Crow24-Oct-07 7:30
David Crow24-Oct-07 7:30 
AnswerRe: Problem!!! Pin
jhwurmbach24-Oct-07 22:39
jhwurmbach24-Oct-07 22:39 
QuestionCreating a form at runtime Pin
Demian Panello24-Oct-07 6:23
Demian Panello24-Oct-07 6:23 
QuestionUsing ADO or OLE DB with VC++ Pin
Stevej24-Oct-07 5:54
Stevej24-Oct-07 5:54 
AnswerRe: Using ADO or OLE DB with VC++ Pin
led mike24-Oct-07 7:13
led mike24-Oct-07 7:13 
GeneralRe: Using ADO or OLE DB with VC++ Pin
Stevej24-Oct-07 8:12
Stevej24-Oct-07 8:12 
GeneralRe: Using ADO or OLE DB with VC++ [modified] Pin
led mike24-Oct-07 8:49
led mike24-Oct-07 8:49 
AnswerRe: Using ADO or OLE DB with VC++ Pin
DQNOK24-Oct-07 11:02
professionalDQNOK24-Oct-07 11:02 
QuestionHow to change windows desktop appearance through VC++/MFC ? Pin
cagespear24-Oct-07 5:46
cagespear24-Oct-07 5:46 
AnswerRe: How to change windows desktop appearance through VC++/MFC ? Pin
David Crow24-Oct-07 5:49
David Crow24-Oct-07 5:49 
AnswerRe: How to change windows desktop appearance through VC++/MFC ? Pin
Hamid_RT25-Oct-07 4:27
Hamid_RT25-Oct-07 4:27 
QuestionData parsers Pin
epsilonorion24-Oct-07 5:33
epsilonorion24-Oct-07 5:33 
AnswerRe: Data parsers Pin
jhwurmbach24-Oct-07 5:57
jhwurmbach24-Oct-07 5:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.