Wie kann ich mein Thread in der Funktion WinMain am Leben halten?



  • Das Programm wird nur einmal ausgeführt.
    Wie kann ich das Programm ohne Dialog laufen lassen?

    Danke 🙂

    static UINT thrFunction (LPVOID pParam);

    UINT thrFunction(LPVOID pParam)
    {
    int* pFlag = (int*) pParam;

    while (*pFlag)
    {
    MessageBox(NULL, _T("thrFunction"), _T("Info"), MB_OK);
    Sleep(10000);
    }
    return 0;
    }

    int WINAPI WinMain(HINSTANCE hInstance,
    HINSTANCE hPrevInstance,
    LPTSTR lpCmdLine,
    int nCmdShow)
    {
    int controlFlag = 1;

    CWinThread* pThread = AfxBeginThread (thrFunction, &controlFlag);

    return 0;
    }



  • WaitForSingleObject() auf den Thread-Handle


Anmelden zum Antworten