I'm working on Ax 4.0
I'm trying to use the Object.setTimeOut method in a job with a local function, as stated in the msdn documentation :
static void setTimeOutJob()
{
Object o = new Object();
void printText()
{
;
info( "2 seconds has elapsed since the user did anything" );
}
;
// Set a Time Out with the idle flag set to false
o.setTimeOut(identifierstr(printText), 2000, false);
}
But this simple job doesn't produce anything, so it seems I'm missing something here.
Has someone worked with this ?
The
setTimeout
method does not work with a local function in a job.For a working example have a look on the form
tutorial_Timer
instead.Update:
The
setTimeout
method is a "magic" function, but it does not turn AX into a multithreading environment.It only works while a Windows event loop is in action. In the AX context it means that a form is running and someone else is waiting for the form to complete. The
sleep
function does not meet the criteria.Also the object must be "alive", calling a garbage collected object is no good!
Example (class based):
I just don't think it works with jobs. I've used it on forms where the method is on the element level, and have done element.setTimeout and it works fine.