task and immediate

Emmanuel Jourdan's icon

Hi,

Is there a way to make a task regular? According to the
documentation, you just have to set the immediate property of the
function to 1 so the Task will be executed in the high priority
thread, but with the example bellow, it reports 1 instead of 0.
If I call the Task from a high priority message, it doesn't change
anything. Am I forgetting something?

ej

PS: this is on a mac, with latest versions of everything...

Max Patch
Copy patch and select New From Clipboard in Max.

--------- save as highpriority.js ---------
var myTask = new Task(click, this);
myTask.interval = 100;

function start()
{
    post("start is in the thread", max.mainthread, "n");
    myTask.repeat();
}
start.immediate = 1;

function stop()
{
    myTask.cancel();
}

function click()
{
    post("task is in the thread", max.mainthread, "n");
    outlet(0, "bang");
}
click.immediate = 1;

ericsays's icon

Warning for Windows users:

This patch crashes Max when overdrive is on, as discussed in a recent thread.

Eric