Csharp/CSharp Tutorial/Thread/Thread Attribute

Материал из .Net Framework эксперт
Версия от 12:20, 26 мая 2010; Admin (обсуждение | вклад) (1 версия)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск

[MTAThread]

using System;
using System.Threading;
class MainClass
{
  [MTAThread]
  static void Main(string[] args)
  {
    Thread primaryThread = Thread.CurrentThread;
    primaryThread.Name = "ThePrimaryThread";
    Console.WriteLine("Thread Name: {0}", primaryThread.Name);
    Console.WriteLine("Alive: {0}", primaryThread.IsAlive);
    Console.WriteLine("Priority Level: {0}", primaryThread.Priority);      
    Console.WriteLine("Thread State: {0}", primaryThread.ThreadState);
  }
}
Thread Name: ThePrimaryThread
Alive: True
Priority Level: Normal
Thread State: Running

[STAThread]

using System;
using System.Threading;
class MainClass
{
  // [MTAThread]
  [STAThread]
  static void Main(string[] args)
  {
    Thread primaryThread = Thread.CurrentThread;
    primaryThread.Name = "ThePrimaryThread";
    Console.WriteLine("Thread Name: {0}", primaryThread.Name);
    Console.WriteLine("Alive: {0}", primaryThread.IsAlive);
    Console.WriteLine("Priority Level: {0}", primaryThread.Priority);      
    Console.WriteLine("Thread State: {0}", primaryThread.ThreadState);
  }
}
Thread Name: ThePrimaryThread
Alive: True
Priority Level: Normal
Thread State: Running