wpf检测点击事件完成而不延迟主进程
我需要检测点击事件中的过程是否已完成,而不延迟主 wpf 进程。
我不想要的
public void click_event(object sender,routedeventargs)
{
<launch a bunch of threads>
while(<threads.are alive>);
<code for what i want to do after threads are done>
}
public void threadtask()
{}
我刚刚做了的
public void click_event()
{
foreach(<thread>)
<give thread task and start() each>
}
}
但这不会检测到何时线程已完成..这里需要帮助。谢谢。
I need to detect a procedure from a click event has finished without delaying the main wpf process..
What I don't want
public void click_event(object sender,routedeventargs)
{
<launch a bunch of threads>
while(<threads.are alive>);
<code for what i want to do after threads are done>
}
public void threadtask()
{}
what i just did
public void click_event()
{
foreach(<thread>)
<give thread task and start() each>
}
}
but this will not detect when the threads are done.. need help here. Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你要求的是两件不同的事情。您希望主线程不被阻塞,但您希望在其他线程完成时执行某些操作(您必须等待)。考虑从一个新线程启动线程,然后让另一个线程完成工作。像这样的事情:
所以所有的工作都在不同的线程上,甚至是你之后想做的工作。鉴于此,您是否需要多个工作线程?
You are asking for two different things. You want the main thread to not be blocked, but you want to do something when the other threads are done (which you have to wait for). Consider starting the threads from a new thread, then let that other thread do the work. Something like this:
So all of the work is on a different thread, even the work you want to do afterward. Given that, do you need more than one worker thread anyway?
查看这篇文章
Check out this article