PRB: Multimedia Timer Hangs in MFC DLL InitInstance

Last reviewed: July 24, 1996
Article ID: Q153867
The information in this article applies to:
  • Microsoft Win32 Software Development Kit for:

        - Microsoft Windows NT, version 3.51
        - Microsoft Windows 95, version 4.0
    

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:

   ARTICLE ID: Q142243
   TITLE     : Cannot Create an MFC Thread During DLL Startup


Additional reference words: 3.51 4.00
KBCategory: kbmm kbprg kbprb
KBSubcategory: MMTimer



THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: July 24, 1996
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.