本文介绍了如何等待线程执行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨朋友



我有一个要求。

我正在使用线程来执行一个方法。但我的问题是在某些时候我需要检查线程是否还活着。如果活着我需要等待完成执行。请看内联评论以便更好地理解。

我怎样才能实现这个



谢谢提前



Hi Friends

I have a requirement.
i am using thread to execute a method. but my problem is at some point i need to check whether the thread is alive. if alive i need to wait to complete the execution.Please see the inline comments for better understanding.
How can i achieve this

Thanks in advance

 Thread thread = new Thread(() => DefectFix.GetReqThreadCall(_iTestFactory, TestContext, out ReqXML2, out GetRequestedDataXML));
 thread.Start();

 DefectFix.GetTopPosThreadCall(_iTestFactory, TestContext, ReqXML, out GetTopPositionXML);
//Below line has  to execute only after thread complete its execution. If execution not completed i need to wait till finish
 DefectFix.ServiceValidation(ReqXML, ReqXML2, GetTopPositionXML, GetRequestedDataXML, TestContext.DataRow["TestCaseName"].ToString(), "GetTopPositions", sb);

推荐答案




这篇关于如何等待线程执行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-04 07:40
查看更多