子线程调用主线程中的函数

admin2022-01-06  3.8K+

import win.ui;
/*DSG{{*/
var winform = win.form(text="aardio form";right=759;bottom=469)
winform.add(
button={cls="button";text="Button";left=125;top=216;right=239;bottom=274;z=1};
button2={cls="button";text="Button";left=312;top=212;right=426;bottom=270;z=2}
)
/*}}*/

import inet.whttp;
whttp = inet.whttp();

winform.button.oncommand = function(id,event){//主线程中干活
	var html = whttp.get("http://www.aardio.org");
	winform.msgbox(html)
}
winform.fun = function(url){//主线程中的干活函数
	var html = whttp.get(url);
	return html; 
}
winform.button2.oncommand = function(id,event){
	thread.invoke( 
		function(winform){
			html = winform.fun("http://www.aardio.org");//子程序中调用主线程的干活函数,并获取返回值
			winform.msgbox(html)
		},winform
	)
}

winform.show();
win.loopMessage();
转载请注明原文地址: https://aardio.net/read-292.html
最新回复(0)
aardio问答
aardio编程语言