Forums > Javascript

Allow JS to yield and allow GUI to update



Lee
Jan 22 2013 | 12:16 pm

Hi, is there anything that can be done in a long process in js to allow the ui to run so that any updates waiting to go to the max window can be made?
thx
L

Jan 24 2013 | 9:41 pm

Not implicitly. You can explicitly break your operation into multiple slices, and use the Task object to periodically call your worker function in slices. e.g. something like the following.


var current_slice=0;
var worker_task = new Task(doslice);

function startwork()
{
  current_slice=0;
  doslice();
}

function doslice()
{
  // do some portion of the work here;
  current_slice++;
  if (current_slice

Lee
Jan 25 2013 | 1:42 pm

Lovely. Thanks for the info :)

Viewing 3 posts - 1 through 3 (of 3 total)

Forums > Javascript