While programming for COM, you must have encountered this annoying “Server Busy” dialog box. This happens when the MFC COM Client is calling some method in the COM Server, that takes a long time to process. Until the method returns, nothing can be done in the client side and this dialog box pops up.
To deal with it, first step is to call AfxOleInit() to initialize COM. According to MSDN, AfxOleInit() also initializes and registers a COleMessageFilter data member in the CWinApp.
Then, use one of the following to deal in your preferred way.
1. 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.
2. 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.
3. Use AfxOleGetMessageFilter()->EnableBusyDialog(FALSE);
to disable the busy dialog box from appearing after the COM call times out.
MSDN says OleInitialize and OleUninitialize instead of AfxOleInit can also suppress the dialog box. But in my case this did not happen.
Credit : http://support.microsoft.com/kb/248019
Filed under: C plus plus, COM | 1 Comment
Tags: AfxOleInit, COleMessageFilter, OLE Server Busy, OleInitialize
Pages
Categories
Archives
Blogroll
-
Recent Posts
- Changing the drag cursor in C#
- Handling System Commands in C#
- Why Comment your code?
- Hide properties inherited from Base class in the PropertyGrid
- Rubber Band / Marquee Selection tool in C#
- A Simple “Print Preview” and “Print” approach in .NET and Java
- How to put combo-boxes into toolbars in Eclipse RCP/Plugin ?
- Alternative to StringBufferInputStream
- How to deal with annoying Server Busy dialog box ?
- BSTR to CString and CString to BSTR Conversion
- Programming Linux Sockets
- Working with COM : Part 3 – Writing COM Client
- Working with COM : Part 2 – Writing your own COM Component
- Working with COM : Part 1 – Basics
- Sleeping Beauty
Unique Hits
Is there a way to do this in .net? I’ve yet to find a way