I created an XPCOM object in C++ for a FireFox extension. I'm using a worker thread to listen for an event and when it happens, I need to do stuff on the main thread. Obviously, I can't just sit and wait in JavaScript on the main thread because you need to be able to use the browser (my event happens very rarely). I tried doing this in the thread (xpcom guy sends javascript an event): window.setTimeout( myImportantWorkFunction, 100 );
This works (on the main thread, as intended), but it will pause indefinately; it doesn't happen after 100ms as intended. You have to click around a bit or resize the window and then suddenly the function gets called. Like JavaScript suddently woke up. I assume this is because it's happening in a thread.
Is there some better way for the worker to ask the main thread to do something?