Question

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?

Was it helpful?

Solution

System.Threading.Thread.CurrentThread.GetApartmentState()

OTHER TIPS

Use this or a similar method inside the function:

System.Threading.Thread.CurrentThread.GetApartmentState
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top