Re: Missing events
spforeman <email@example.com> wrote:
My ATL server does the following (in a worker thread):
1, Fires an event to indicate progress to the client.
2, Retrieves an image from a camera.
3, Performs a calculation on the image.
4, Moves a cameras lens. (via 3rd party COM server)
5, Waits for an event from the 3rd party server to indicate camera
lens has stopped moving.
6, Repeats the above if not finished.
The above sequence works fine. However, if I do not perform point 1
then I never receive an event (point 5) from the 3rd party server!
My psychic powers tell me that you have a thread join STA (by calling
CoInitialize), but this thread doesn't run a message pump. This is a big
no-no: a thread that joins STA must run the message pump.
The reason you receive events when you fire your own is as follows: when
you fire an event, you actually perform an out-of-apartment COM call.
When such a call originates from STA apartment, COM spins a modal
message pump while waiting for the call to return. While this message
pump runs, you get incoming COM calls reentrantly.
For more details, see http://support.microsoft.com/kb/150777
In my code I perform the above 6 steps about 20 times in a loop
(without problem) and then one final time, but without firing the
progress event (step 1), now it gets stuck waiting for the event (step
How exactly are you "waiting" for an event? What is your thread doing
during this time?
With best wishes,
With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925