ATL: Firing Events from Worker Threads

If You have ever the problem : "VB client keep crashing when compiled and not in the IDE if it has a worker thread" then here is a possible solution.

In most cases of my work I develop ATL objects with worker threads. In the worker threads there must be often fire events
for signalling thread states.
The problem of firing events from worker thread is that they must enter another apartment. In this apartment the sink interfaces
are not valid and thats why some clients would not be receive the events (eg VB).
I found a simple solution for that. (A solution without PostMessage.)

Only the proxy code of wizard must be changed, to get the firing of events right. I use the global interface table (GIT) for my solution.
"The GIT holds a list of marshaled interface pointers that, on request can be unmarshaled any number of times to any number of apartment in your
process, regardless of whether the pointer is for an object or a proxy."(Professional ATL COM Programming, Dr Richard Grimes).

I wrote a new specialized class for CComDynamicUnkArray which use the GIT for accessing the sink interfaces.

Top White Papers and Webcasts

Entire organizations suffer when their networks can't keep up and new opportunities are put on hold. Waiting on service providers isn't good business. In these examples, learn how to simplify network management so that your organization can better manage costs, adapt quickly to business demands, and seize market opportunities when they arise.

Today's enterprise datacenter can be one of the most complex business environments with dozens (for smaller business), hundreds (for larger and midsize business), even thousands (for hyperscale businesses) of servers that must be managed and monitored. At this level, just managing the cords can be challenging — let alone keeping up with the growing need for more agility and scalability within the datacenter. Simply put, companies are aggressively looking for less complexity and more agility from their …