2011-03-23 29 views
0

我在我的項目中有一些代碼,如下所示,這裏STA線程的用法是什麼? 我對STA的瞭解是單線程公寓,它只在使用COM組件時才需要,它在應用程序的主要條目中使用。窗口應用程序中的STA線程

/// <summary> 
     /// The main entry point for the application. 
     /// 
     /// Command line: 
     /// Leaf.exe /s server-name 
     /// </summary> 
     [STAThread] 
     static void Main() 
     { 

       Application.EnableVisualStyles(); 
       Application.SetCompatibleTextRenderingDefault(false); 
       Application.DoEvents(); 
       Application.Run(new Leaf()); // Leaf is a constructor 

     } 
+0

這可能會幫助你http://stackoverflow.com/questions/127188/could-you-explain-sta-and-mta – 2011-03-23 07:43:49

回答

0

MSDN answers your questions

這對其他功能沒有任何影響。它只對你的程序使用COM互操作有效。

+0

謝謝我認爲它會影響Application.EnableVisualStyles()etcc .. – peter 2011-03-23 07:43:14