x++


setTimeOut and local function


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):
class SetTimeoutTest extends Object //Yes, extend or it will not compile
{
str test;
}
public void new()
{
super();
test = "Hello";
}
public str test()
{
return test;
}
protected void timedOut()
{;
test = "2 seconds has elapsed since the user did anything";
info(test);
}
static void main(Args args)
{
SetTimeoutTest t = new SetTimeoutTest();
FormRun fr;
;
t.setTimeOut(methodStr(SetTimeoutTest,timedOut), 2000, false);
//sleep(4000); //Does not work
fr = ClassFactory::formRunClassOnClient(new Args(formstr(CustGroup))); //Could be any form
fr.init();
fr.run();
fr.wait(); //Otherwise the t object runs out of scope
info(t.test());
}
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.

Related Links

Dynamics AX 2012 parsing Int32 to table field integer
Cancel Sales order packing slip through x++
Transferring open account records between customers
How to make sure that a form is only opened once?
Extend system menu in Dynamics AX 2012?
How to show selected items of certain table on the different table in Dynamics AX 2012?
AllowEdit doesn't work properly in Dynamics AX
AX 2012 how to set args record datasource in X++
Clients seem to be running old (buggy) code after XPO project import
Number sequence AX 2012
SSRS MS words report with page break
How can you get a detailed error descriptions in Dynamics AX?
How to get the length of an array?
X++ loop through lines in grid control
Concatenating row values in x++
How do you access a macro in the AOT macro node?

Categories

HOME
cobalt
rdbms
opendj
parameters
tail
onclick
limit
vsm
data-visualization
azure-container-service
recordrtc
rcloud
fabric.io
g++
fhir
line
filechannel
selenium-ide
coin3d
aws-sdk
pyramid
topology
lilypond
backpack-for-laravel
tosca
epsilon
siri
fat
angularjs-components
oculus
errbot
jaws
twiml
ntp
nsurl
anki
dst
getpixel
jwplayer6
baidu-map
servicestack-text
salesforce-communities
verifiable-c
skylink
attributeerror
softmax
naming
preloader
smoothstate.js
strftime
facebook-social-plugins
openrasta
clarifai
openblas
zenhub
colorbar
android-testing
excel-dna
filehandle
template-toolkit
smartfoxserver
qtplugin
mta
hclust
ikiwiki
nio2
contentcontrol
jaunt-api
custom-errors
vigenere
microsoft-reporting
morton-number
vacuum
apache-commons-daemon
teamcity-9.1
matlab-deployment
cakephp-2.7
delayed-execution
punycode
rmysql
rcaller
drupal-nodes
spring-3
inappsettingskit
actiondispatch
pagedown
video-codecs
fb.ui
azman
user-tracking
catransform3d
xcelsius
automationelement
uipagecontrol
appledoc
globals
jqueryform
drupal-fivestar
cfwindow
murmurhash
lxr
lalr
lobo-cobra
software-lifecycle

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App