Microsoft KB Archive/248019

From BetaArchive Wiki
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.
Knowledge Base


How to prevent the OLE Server Busy dialog box from appearing during a lengthy COM operation

Article ID: 248019

Article Last Modified on 11/21/2006



APPLIES TO

  • Microsoft Foundation Class Library 4.2, when used with:
    • Microsoft Visual C++ 5.0 Enterprise Edition
    • Microsoft Visual C++ 6.0 Enterprise Edition
    • Microsoft Visual C++ .NET 2002 Standard Edition
    • Microsoft Visual C++ .NET 2003 Standard Edition



This article was previously published under Q248019

Note Microsoft Visual C++ .NET (2002) supports both the managed code model that is provided by the Microsoft .NET Framework and the unmanaged native Microsoft Windows code model. The information in this article applies only to unmanaged Visual C++ code.

SUMMARY

If you call a method on a COM server from an MFC COM client application and if the method takes a long time to process and return back, you won't be able to do anything on the client application and the OLE Server Busy dialog box pops up. This article explains how you can increase the time-out period of the COM call and also shows you how to avoid this dialog box.

MORE INFORMATION

Ensure that the MFC client application is calling AfxOleInit() to initialize COM. This is important, because AfxOleInit() also initializes and registers a COleMessageFilter data member in the CWinApp. Alternatively, you can create your own COleMessageFilter object and register that during the startup.

Use

AfxOleGetMessageFilter()->SetMessagePendingDelay(nTimeout);
                

to set the wait period on outgoing COM calls. If the COM call takes longer than nTimeout milliseconds, then the MFC Client application displays the OLE Server Busy dialog box.

Use,

AfxOleGetMessageFilter()->EnableNotRespondingDialog(FALSE);
                

to disable the Not Responding dialog box, which is displayed if a keyboard or mouse message is pending during an OLE call and the call has timed out.

Use

AfxOleGetMessageFilter()->EnableBusyDialog(FALSE);
                

to disable the busy dialog box from appearing after the COM call times out.

Another way to suppress the server busy dialog box is to use OleInitialize and OleUninitialize instead of AfxOleInit in your application.

REFERENCES

For more information, click the following article number to view the article in the Microsoft Knowledge Base:

179692 An HRESULT of 0x80010005 error occurs when you try to call methods on a COM server in Visual C++


For additional information, see the following Microsoft Developer Network (MSDN) Web sites:


Additional query words: restrict stops obstructs useless unwanted display IMessageFilter

Keywords: kboleapp kbarchitecture kbautomation kbdcom kbfaq kbhowto KB248019