如何在C#中获取正在运行的线程状态 [英] How to get a Running thread state in C#

查看:1248
本文介绍了如何在C#中获取正在运行的线程状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

HI朋友,





我一次运行超过10个线程。我想只在thread1完成其工作时才执行操作。线程3必须等到线程2完成....再次相同会一个接一个地发生。





任何人都可以建议我我怎么能这样做....



我刚刚使用Join()但收到错误:



HI Friend,


I am running more than 10 threads at once. I want to perform an operation only when thread1 is completes its job. Again thread 3 has to wait until thread 2 finishes.... again same will happen one by one.


Can anyone suggest me how can i do this....

I just made use of Join() but getting an error:

An asynchronous call is already in progress. It must be completed or canceled before you can call this method. System.InvalidOperationExceptionStackTrace: at  System.Net.Mail.SmtpClient.Send(MailMessage message)









请帮助我....





Please help me in this regard....

推荐答案

Thread.ThreadState or Thread.Join if you want to wait for your threads. Or use Semaphore





Thread.join方法


使用thread.waitone

这将等待直到当前完成。
use thread.waitone
this will wait until current gets completed.


你应该在这里使用多线程通信。这是一篇文章如何:



.NET多线程和线程之间的通信 [ ^ ]
You should be using multiple thread communication here. Here is an article how:

.NET multi-threading and communication between threads[^]


这篇关于如何在C#中获取正在运行的线程状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆