我正在开发 Axe 4.0
我正在尝试在具有本地函数的作业中使用 Object.setTimeOut 方法,如中所述msdn 文档: http://msdn.microsoft.com/en-US/library/aa857865%28v=ax.10%29
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);
}
但这个简单的工作不会产生任何东西,所以我似乎在这里遗漏了一些东西。
有人用过这个吗?
The setTimeout
方法不适用于作业中的本地函数。
对于一个工作示例,请查看表格tutorial_Timer
反而。
Update:
The setTimeout
方法是一个“神奇”功能,但它不会将 AX 转变为多线程环境。
它仅在 Windows 下有效事件循环 http://en.wikipedia.org/wiki/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());
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)