I've written a windowless NPAPI plugin, and I am going to perform some long lasting operation (e.g.send a http post request with image data) in a plugin function called by web browser JavaScript. Web browser must wait for plugin's worker thread to complete its job before doing anything else.
To prevent web browser from hanging, I create a worker thread for the lengthy operation in my plugin function.
My question is that how to properly wait the thread to complete in the plugin function, and without browser hanging at the same time?
The following code seems only works in window mode applications as far as I know.
// on Main thread
while (WaitForSingleObject(hWorkerThread, 100) == TIMEOUT)
{
while (PeekMessage(...))
{
TranslateMessage(...);
DispatchMessage(...);
}
}
Any help will be really appreciated.