卓越飞翔博客卓越飞翔博客

卓越飞翔 - 您值得收藏的技术分享站
技术文章20008本站已运行345

检查当前线程状态的 C# 程序

检查当前线程状态的 C# 程序

To check the status of the current thread in C#, use the IsAlive property.

Firstly, use the currentThread property to display information about a thread −

Thread thread = Thread.CurrentThread;

Now use the thread.IsAlive property to check the status of the thread −

thread.IsAlive

Example

Let us see the complete code to check the status of current thread in C#.

Live Demo

using System;
using System.Threading;
namespace Demo {
   class MyClass {
      static void Main(string[] args) {
         Thread thread = Thread.CurrentThread;
         thread.Name = "My New Thread";
         Console.WriteLine("Thread Status = {0}", thread.IsAlive);
         Console.ReadKey();
      }
   }
}

输出

Thread Status = True
卓越飞翔博客
上一篇: PHP图片上传与裁剪技巧大全
下一篇: 返回列表
留言与评论(共有 0 条评论)
   
验证码:
隐藏边栏