I have a third-party COM object that I am calling that uses an event callback to signal that it has completed its task.
obj.Start();
then after a while he will raise an event to say that it is done.
void OperationFinished()
I would like to do this operation synchronously and tried to use AutoResetEvents to handle this
eg.
obj.Start();
m_autoReset.WaitOne();
and in the event handler:
void OperationFinished()
{
m_autoReset.Set();
}
but it seems that both Set () and WaitOne () are in the same thread, so it gets stuck. Is there an easy way to handle this?
source
share