代码之家  ›  专栏  ›  技术社区  ›  Marin

Win32,在主消息队列中等待线程?

  •  0
  • Marin  · 技术社区  · 14 年前

    while(GetMessage(&msg, NULL, 0, 0))
    {
    
        if (!done){
            GetExitCodeThread(dThread,&dwCode);
            if (dwCode!=STILL_ACTIVE){
                //thread done
            }
        }
    
    if (!IsDialogMessage (UWnd, & msg))
        {
            TranslateMessage ( & msg );
            DispatchMessage ( & msg );
        }
    }
    

    这可以正常工作,但是如果线程完成,它将不会触发,直到窗口上的某个操作完成(鼠标、焦点等)。当收到消息或线程完成时,我如何才能拥有循环触发器?

    3 回复  |  直到 14 年前
        1
  •  5
  •   Ferruccio    14 年前

    您可以让线程向您的UI线程发送消息(使用 PostThreadMessage

        2
  •  2
  •   mistachkin    14 年前

    你看过MsgWaitForMultipleObjectsEx函数吗?

        3
  •  1
  •   Chris Becke    14 年前