如何检查是否线程执行完毕 [英] How to check if Thread finished execution
本文介绍了如何检查是否线程执行完毕的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下问题:
我要检查(C#)如果一个线程执行结束,即如果线程方法返回。我现在要做的就是调用的Thread.join(1)
,但这给出了1毫秒的延迟。有没有办法简单地检查一个线程完成。检查 Thread.ThreadState
似乎只是太麻烦了。
I want to check (C#) if a thread has finished execution, i.e. if the thread method has returned. What I do now is call Thread.Join(1)
, but this gives a 1 ms delay. Is there any way to simply check if a thread has finished. Inspecting Thread.ThreadState
just seems too cumbersome.
推荐答案
为什么不的 Thread.IsAlive
标志。这是给线程状态
Why not Thread.IsAlive
flag. This is to give the thread status.
这篇关于如何检查是否线程执行完毕的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文