2011-03-23 28 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