I need a message pump that doesn't mess up my open window

前端 未结 4 1212
自闭症患者
自闭症患者 2021-01-28 02:07

My application (the bootstrap application for an installer that I\'m working on needs to launch some other applications (my installer and third party installers for my installer

4条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-28 02:52

    I think your problem is in WaitForSingleObject

    Looking in MSDN you see this

    Use caution when calling the wait functions and code that directly or indirectly creates windows. If a thread creates any windows, it must process messages. Message broadcasts are sent to all windows in the system. A thread that uses a wait function with no time-out interval may cause the system to become deadlocked. Two examples of code that indirectly creates windows are DDE and the CoInitialize function. Therefore, if you have a thread that creates windows, use MsgWaitForMultipleObjects or MsgWaitForMultipleObjectsEx, rather than WaitForSingleObject.

    In my code in the message pump use use MsgWaitForMultipleObjects (doc).

    With a call this call.

    MsgWaitForMultipleObjects(1, &ProcessInfo.hProcess, FALSE, 100, QS_ALLEVENTS); 
    

    This should stop your problem with the resources dissapearing.

提交回复
热议问题