문제

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?

도움이 되었습니까?

해결책

System.Threading.Thread.CurrentThread.GetApartmentState()

다른 팁

Use this or a similar method inside the function:

System.Threading.Thread.CurrentThread.GetApartmentState
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top