遇到这样的问题,在wpf的main thread(UI thread)里面要启动一个process,这个process可能要花》10分钟的时间,于是就用了另外一个线程T2做这个工作,然后main thread再去做其他事情(比如响应其他输入)。 问题是如何在T2中的process结束时候向main thread发出请求,然后main thread 再做后继的处理工作(比如输出process的返回值)?比如
public class Window1:Window
{
onButtonRunclick()
{
start thread2
}
.....
}thread2
{
create/init WorkProcess.
WorkProcess.start();
WorkProcess.waitforexit(); // Can last 30 mins...
int error = WorkProcess.ExitCode;
}或者干脆能不能取消thread2, 在workProcess()的exit事件里面向main UI 发送一个进程间
消息来通知一下?谢谢各位大侠
public class Window1:Window
{
onButtonRunclick()
{
start thread2
}
.....
}thread2
{
create/init WorkProcess.
WorkProcess.start();
WorkProcess.waitforexit(); // Can last 30 mins...
int error = WorkProcess.ExitCode;
}或者干脆能不能取消thread2, 在workProcess()的exit事件里面向main UI 发送一个进程间
消息来通知一下?谢谢各位大侠
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货