W
William Johnston
Hello,
I need to perform synchronous calls to a DllImport function that is asychronous. (The Dllmport function returns immediately.)
So far I have a timer that waits inside a ThreadPool queue. But I would rather not use anything close to time-sharing.
Here is my code:
[
void mainloop ()
{
// call to asynchronous DllImport function
CreateVOBSegment(hwnd, strSourceVOBFilename, strBegTimeStamp, strEndTimeStamp, strDestFilename);
ThreadPool.QueueUserWorkItem(new WaitCallback(VOBExtractParser.Sleep), autoEvent);
autoEvent.WaitOne();
}
}
/// <summary>
/// thread that waits for 20 seconds
/// </summary>
private static void Sleep(object stateInfo) {
Thread.Sleep(TIMEOUT);
((AutoResetEvent)(stateInfo)).Set();
}
]
Do you have any suggestions?
Regards,
William Johnston
I need to perform synchronous calls to a DllImport function that is asychronous. (The Dllmport function returns immediately.)
So far I have a timer that waits inside a ThreadPool queue. But I would rather not use anything close to time-sharing.
Here is my code:
[
void mainloop ()
{
// call to asynchronous DllImport function
CreateVOBSegment(hwnd, strSourceVOBFilename, strBegTimeStamp, strEndTimeStamp, strDestFilename);
ThreadPool.QueueUserWorkItem(new WaitCallback(VOBExtractParser.Sleep), autoEvent);
autoEvent.WaitOne();
}
}
/// <summary>
/// thread that waits for 20 seconds
/// </summary>
private static void Sleep(object stateInfo) {
Thread.Sleep(TIMEOUT);
((AutoResetEvent)(stateInfo)).Set();
}
]
Do you have any suggestions?
Regards,
William Johnston