Live Chat Icon For mobile
Live Chat Icon

What is the purpose of the [STA Thread] attribute for the Main method of a C# program

Platform: WinForms| Category: Tips

That marks the thread as being ‘Single Thread Apartment’ which means any multiple threaded calls need to be marshaled over to that thread before they are called. That’s there because Windows Forms uses some OLE calls
(Clipboard for example), which must be made from the thread that initialized OLE.

(from sburke_online@microsoft..nospam..com on microsoft.public.dotnet.framework.windowsforms)

Share with

Share on twitter
Share on facebook
Share on linkedin

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.