Search code examples
c#.netmultithreadingstaapartment-state

How to check apartment state of current thread?


I have a function which requires to be run in STA apartment state. I wan't to check if it is being run as STA, and if not spawn a new thread which runs in STA.

How can I check which apartment state the current thread is being run in?


Solution

  • System.Threading.Thread.CurrentThread.GetApartmentState()