หากต้องการแสดงลำดับความสำคัญของเธรดใน C# ให้ใช้ ลำดับความสำคัญ ทรัพย์สิน
ประการแรก ใช้ currentThread คุณสมบัติเพื่อแสดงข้อมูลเกี่ยวกับเธรด -
Thread thread = Thread.CurrentThread;
ตอนนี้ใช้ thread.Priority คุณสมบัติเพื่อแสดงลำดับความสำคัญของเธรด -
thread.Priority
ตัวอย่าง
ให้เราดูโค้ดทั้งหมดเพื่อแสดงลำดับความสำคัญของเธรดใน C#
using System;
using System.Threading;
namespace Demo {
class MyClass {
static void Main(string[] args) {
Thread thread = Thread.CurrentThread;
thread.Name = "My Thread";
Console.WriteLine("Thread Priority = {0}", thread.Priority);
Console.ReadKey();
}
}
} ผลลัพธ์
Thread Priority = Normal