static void Main()
You must have noticed the above-given entry point Main() method in the program.cs class of all .NET windows forms applications are always decorated with the attribute STAThread.
What is [STAThread] Attribute? What Does [STAThread] Mean?
Attribute [STAThread] is a mandatory attribute for all windows forms application. STAThread attribute needs to be applied to set the current thread apartment state as single threaded.
This means that the COM threading model for the application is a single-threaded apartment.
What Does [STAThread] Do?
STAThreadAttribute is carried over from COM. STAThread attribute specifies the communication mechanism between the current thread and other threads that may want to talk to it via COM.
Windows Forms applications may use COM interop in order to communicate with operating system components such as File Dialogs, Clipboard etc.If our application is not able to control the state of the apartment of the current running thread, it should start up a new thread.
Apartment style declaration is mandatory for Windows Forms applications.If apartment style not declared, it may be that some other component which communicates your windows application will declare an apartment style for your windows application improperly.