views:

34

answers:

1

I am currently working with a third party ActiveX control where I need to detect when an event I called from the API has completed.

Looking at the ActiveX control in VS 2008 Object browser, I call public virtual bool MyMethod() and there is an event public virtual event IActiveXObject_MyMethodEventHandler SettleComplete.

There is also a delegate _IActiveXObjectEvents_MyMethodCompleteEventHandler() that is part of the assembly

How would I write the code to configure my application to detect when the event from ActiveX control is complete?

A: 

You could use a thread synchronization method in which you have an object like an event used to signal when the event is finished.

ManualResetEvent e = new ManualResetEvent();
e.Reset();
CallMyFunction();
e.WaitOne();

and at the end of the handler:

e.Set();

That is, if I understand the question correctly...