gpt4 book ai didi

x++ - setTimeOut 和本地函数

转载 作者:行者123 更新时间:2023-12-04 05:40:10 24 4
gpt4 key购买 nike

我正在开发 Ax 4.0
我正在尝试在具有本地函数的作业中使用 Object.setTimeOut 方法,如 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);
}
但是这个简单的工作并没有产生任何东西,所以我似乎在这里遗漏了一些东西。
有人用过这个吗?

最佳答案

setTimeout方法不适用于作业中的局部函数。

有关工作示例,请查看表单 tutorial_Timer相反。

更新:
setTimeout方法是一个“神奇”的函数,但它不会将 AX 变成多线程环境。

它仅适用于 Windows event loop正在行动。在 AX 上下文中,这意味着表单正在运行,而其他人正在等待表单完成。 sleep功能不符合标准。

此外,对象必须“活着”,调用垃圾收集对象是不行的!

示例(基于类):

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());
}

关于x++ - setTimeOut 和本地函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11359271/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com