Hi,
"session.identify" is a third party COM API that I call and have no access to. It performs a server query that, somehow, locks up occasionally (and thus halts the main program which is waiting for the result).
My attempt was to wrap it in an AsyncDelegate so I would be able to give it a timeout and after expiration of the timeout allow the main program to proceed (similar to this one, just with a return value). However, it still locks up without the timeout having an effect.
Am I using the AsyncHandle.WaitOne incorrectly? Could there be something in the API that prevents it from being aborted?
private delegate void AsyncIdentifyCaller(CoAudioIdSignature signature, uint numResults, uint serverFlags , out IIdentifyResult result);
private IIdentifyResult identifyAndWait(CoAudioIdSession session, CoAudioIdSignature signature, uint numResults, out IIdentifyResult iresult)
{
AsyncIdentifyCaller identifyDelegate = new AsyncIdentifyCaller(session.Identify);
IAsyncResult result = identifyDelegate.BeginInvoke(
signature,
numResults,
0,
out iresult,
null,
null);
// wait up to timeout [ms] and then continue without a proper result
int timeout = 30000;
result.AsyncWaitHandle.WaitOne(timeout, false);
identifyDelegate.EndInvoke(out iresult, result);
return iresult;
}