[html5] Is there any way to processmessages inside a worker?

Ian Hickson ian at hixie.ch
Mon Jul 12 15:52:06 PDT 2010


On Mon, 12 Jul 2010, Marcelo Saviski wrote:
>
> It's possible?
> 
> inside the myworker.js:
> 
> onmessage = function() {
> >   //why you don't call me?
> > }
> >
> > while (true) {
> >   doSomething();
> >   processMessages(); //check for waiting message in the message queue
> > }

The "onmessage" handler won't be called while you have code running. You 
have to do it the same way you do outside of workers, e.g.:

   onmessage = processMessage();
   setInterval(0, doSomething);

-- 
Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'



More information about the Help mailing list