PRB: Multimedia Timer Hangs in MFC DLL InitInstance (153867)



The information in this article applies to:

  • Microsoft Platform Software Development Kit (SDK) 1.0, when used with:
    • Microsoft Windows 3.1
    • Microsoft Windows 3.11
    • Microsoft Windows 95
    • Microsoft Windows NT Server 3.5
    • Microsoft Windows NT Server 3.51
    • Microsoft Windows NT Workstation 3.5
    • Microsoft Windows NT Workstation 3.51

This article was previously published under Q153867
4.00 | 3.51 WINDOWS | WINDOWS NT kbprg kbprb

SYMPTOMS

Calling timeSetEvent() from an MFC DLL's CWinApp::InitInstance() override never returns.

CAUSE

Whenever a thread is created that will use code in the MFC DLL, an MFC- supplied DLLMain calls the InitInstance() override. The DLLMain code is suspended and does not clean up and exit until its call into InitInstance() returns. Calling timeSetEvent() from InitInstance() leads to an attempted creation of another thread needed by the Multimedia Timer. This additional thread leads to another call into DLLMain that has not yet finished with the earlier InitInstance() call. Therefore, the creation of the Multimedia Timer thread hangs waiting for the completion of the earlier thread.

RESOLUTION

Do not create a Multimedia Timer in InitInstance() of an MFC DLL. Create the Multimedia Timer in a DLL function that is exported and is therefore called from outside the scope of DLLMain.

STATUS

This behavior is by design.

REFERENCES

For more information, please see the following article in the Microsoft Knowledge Base:

142243 Cannot Create an MFC Thread During DLL Startup


Modification Type:MinorLast Reviewed:7/11/2005
Keywords:kbmm KB153867