MFC 防止多线程卡死

    Par p;
    p.CmdLine = _T("ping 127.0.0.1");
    HANDLE handle = CreateThread(NULL, 0, ExecuteCmd, &p, 0, NULL);
    while (TRUE){
        DWORD result;
        MSG msg;
        result = MsgWaitForMultipleObjects(1, &handle, FALSE, INFINITE, QS_ALLINPUT);
        if (result == (WAIT_OBJECT_0)){
            break;
        }
        else{
            PeekMessage(&msg, NULL, 0, 0, PM_REMOVE);
            DispatchMessage(&msg);
        }
    }
    m_edit_result = p.ret;
posted @ 2017-12-20 22:16  老耗子  阅读(101)  评论(0编辑  收藏  举报