简体   繁体   中英

STA thread in windowapplication

I have a bit of code in my project like shown below,here what is the usage of STA thread ? 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.

/// <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

It has no effect on other functions. It only has effect if your program uses COM interop.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM