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

How to Edit address using X++ in AX 2012
Number sequence issue Ax 2012?
Find code that's running in a Batch Job
What is the _isMexican boolean for in the Global::Checkpower method?
AlwaysOnTop property not behaving properly
Boolean AND logic in Microsoft Dynamics AX 2012 AIF QueryCriteria
Table: PrintMgmtSettings Field: Printjobsettings(Blob)
What happened to the hrplimittablerelationship table in ax-2012-r2?
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

Categories

HOME
batch-file
embedded
turing-machines
github-for-windows
angular2-material
themes
hessian
fftw
sitecore
tvos
webix
accessibility
openpyxl
ibeacon-android
fhir
ipmitool
filechannel
shared-libraries
renjin
docx
bitnami
azure-powershell
dimensional-modeling
fileserver
ag
user-experience
babel
visual-studio-extensions
xunit
data.stackexchange.com
siri
google-cloud-print
has-and-belongs-to-many
inversion-of-control
quantlib
gp
finagle
mailkit
activexobject
nested-lists
swagger-php
docfx
jpad
timing
release
filesystemwatcher
sim-card
recurrent-neural-network
kill
ogc
install.packages
ssrs-2014
signal-strength
show-hide
plan-9
textsum
opennms
posixct
custom-font
boxing
subnet
java-websocket
universal-analytics
bootstrap-tags-input
structuremap4
restore
flex4.6
windows-azure-queues
angular-ui-typeahead
nio2
libvlc
roadkill-wiki
ons-api
vacuum
linked-tables
diff3
ejb-2.x
beatsmusic
mruby
big-ip
wcm
high-resolution
kendo-dataviz
oocss
jquery-1.9
pagedown
pdfviewer
rmiregistry
garbage
fusefabric
jsr286
urlrewriter
node-redis
fsevents
google-ajax-api
pylucene
uipagecontrol
blender-2.49
entitykey

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