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



One Response to “How to deal with annoying Server Busy dialog box ?”  

  1. 1 nth78

    Is there a way to do this in .net? I’ve yet to find a way


Leave a Reply