[英]STA thread in windowapplication
I have a bit of code in my project like shown below,here what is the usage of STA thread ? 我的项目中有一些代码,如下所示,这里STA线程的用法是什么? What i know about STA is it is Single Threaded Apartment,it is only required when using COM components.And it is used in the main entry of the application. 我对STA的了解是单线程公寓,仅在使用COM组件时才需要。它在应用程序的主条目中使用。
/// <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
}
MSDN answers your questions MSDN回答您的问题
It has no effect on other functions. 它对其他功能没有影响。 It only has effect if your program uses COM interop. 它仅在您的程序使用COM互操作时才有效。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.