How to avoid "Illegal to call out while in message filter"

I have a VB app calling methods in an object created in an .EXE automation server (written in C++ MFC). Two different VB forms are accessing two different objects in the same .EXE server. In general, things work fine, but I seem to get occasional collisions when both VB forms are accessing the server and one reports an automation error 0x8001005 ("Illegal to call out while inside message filter"). The one reporting the error is being wakened by a timer to make periodic calls (which work most of the time). How is this caused and can it be avoided?

Check out articles Q176399 and Q138063 in the Microsoft knowledge base for some enlightenment about timers and the windows message queue and RPC in out of process servers. You can use the timer, but you have to set some flags to avoid re-entrancy.

0

Featured Post

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Introduction
While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC. I didn't post completely correct code o…

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.
There is also a companion Debug Toolbar that looks like the followin…

Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…