एक नया सूत्र बनाने के लिए।
Thread thread = Thread.CurrentThread; thread.Name = "My new Thread”;
वर्तमान प्रसंग आईडी प्राप्त करने के लिए, ContextID गुण का उपयोग करें।
Thread.CurrentContext.ContextID
आइए देखें पूरा कोड -
उदाहरण
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 Name = {0}", thread.Name);
Console.WriteLine("current Context id: {0}", Thread.CurrentContext.ContextID);
Console.ReadKey();
}
}
} आउटपुट
Thread Name = My new Thread current Context id: 0