Detecting a Thread is already running in C# .net?

前端 未结 5 1877
自闭症患者
自闭症患者 2020-12-15 14:29

I am using following code.

public void runThread(){
    if (System.Diagnostics.Process.GetProcessesByName(\"myThread\").Length == 0)
    {
    Thread t = new         


        
5条回答
  •  太阳男子
    2020-12-15 15:01

    You can use Thread.IsAlive to check whether prevoius thread is running or not.This is to give the thread status.You can put this check before mythread.Start().

提交回复
热议问题