Posting messages from a web worker during a long-running for-next loop

时间:2015-05-12 23:45:38

标签: javascript web-worker

I'm using a web worker to handle some CPU-intensive calculations that take about 10 seconds to run. The calculation requires a for-next loop.

So, roughly, in the web worker, it looks like this:

if (pet == NULL) // or nullptr
{
    ...
}

This works great in Chrome and Safari on OS X - every 10,000 iterations, the parent receives the 'progress' message with the percent complete, and the 'complete' message when the loop is finished.

However, it does not seem work in IE11 or Firefox 37 - only the 'complete' message is sent.

Is this a bug in IE11 and/or Firefox, or just an implementation difference?

Is there a way to accomplish this in IE/Firefox without resorting to setIntervals, or splitting apart the for-next loop (which feels hacky...)?

0 个答案:

没有答案