Rob
Rob

Reputation: 78688

Firing COM events in C++ - Synchronous or asynchronous?

I have an ActiveX control written using the MS ATL library and I am firing events via pDispatch->Invoke(..., DISPATCH_METHOD). The control will be used by a .NET client and my question is this - is the firing of the event a synchronous or asynchronous call? My concern is that, if synchronous, the application that handles the event could cause performance issues unless it returns immediately.

Upvotes: 0

Views: 1270

Answers (1)

Rob Walker
Rob Walker

Reputation: 47482

It is synchronous from the point of view of the component generating the event. The control's thread of execution will call out into the receivers code and things are out of its control at that point.

Clients receiving the events must make sure they return quickly. If they need to do some significant amount of work then they should schedule this asynchronously. For example by posting a windows message, or using a separate thread.

Upvotes: 4

Related Questions