How to check apartment state of current thread?

2019-03-22 17:35发布

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?

2条回答
We Are One
2楼-- · 2019-03-22 18:02
System.Threading.Thread.CurrentThread.GetApartmentState()
查看更多
甜甜的少女心
3楼-- · 2019-03-22 18:09

Use this or a similar method inside the function:

System.Threading.Thread.CurrentThread.GetApartmentState
查看更多
登录 后发表回答