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

Why is my changes ignored to releaseupdate scripts in dynamics ax 2012 r2
What is “old sys” exactly and why would I receive errors in 2012 because of a missing Macro?
How to filter records in line grid based on selected record in header grid?
Dynamic linking gets cleared when inserting new records
Box::info showing “refreshEx”
How to filter lookup values on a dialogfield in Report Dialog based on another dialogfield in AX 2012 AOT reports?
Adding scrollbar to a Group in AX 2012 form
Table query inconsistent
AX2012 Sales Order Creation through AX Classes
How can I loop over Tables which contain specific characters in their AOT name and delete the data?
Having button that runs code, but doesn't submit data to (or validates against) table
Where are Duties (table name) stored in AX?
Advanced query range
How to read from an Excel file?
group by clause in X++
Determine the number of affected rows by an update_recordset call in Dynamics 4.0?

Categories

HOME
depth
powerpoint
numbers
solver
static-site
limit
trac
syntaxnet
heap
project-intu
redis-sentinel
shared-libraries
libusb
alpacajs
android-7.0-nougat
lilypond
symbols
googlebot
dpdk
ios10.2
epsilon
highstock
interpreter
data.stackexchange.com
fractions
sinch
python-2.6
mockjax
jmockit
git-squash
catch-unit-test
baidu-map
navigator
parse-tree
openalpr
diacritics
attributeerror
drupal-theming
vaadin-charts
oim
automapper-5
twilio-click-to-call
truezip
bbpress
java-websocket
google-photos
reachability
gets
cronexpression
preprocessor
adafruit
greatest-n-per-group
ng-grid
observablecollection
embedding
cfchart
phpwebsocket
kendo-upload
vhosts
custom-errors
linklabel
oracle-spatial
android-launcher
doctype
batik
iced-coffeescript
finalbuilder
jsvc
omnifaces
crowd
nsmenu
template-deduction
codeplex
paste
radiant
renderer
maven-scm
square-bracket
sphinxql
isqlquery
mongohq
booksleeve
patricia-trie
monotouch.dialog
xcode3.2
veracity
adobe-media-server
objectquery
thttpd
predicatebuilder
xcelsius
creole
codebase
cloudfiles
non-clustered-index
eclipse-marketplace
hbm2java
django-piston
echo3
lalr
mathematical-notation
windows-identity
linfu-dynamicproxy

Resources

Database Users
RDBMS discuss
Database Dev&Adm
javascript
java
csharp
php
android
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App