How to check apartment state of current thread?

99封情书 提交于 2019-12-04 15:27:40

问题


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?


回答1:


System.Threading.Thread.CurrentThread.GetApartmentState()



回答2:


Use this or a similar method inside the function:

System.Threading.Thread.CurrentThread.GetApartmentState


来源:https://stackoverflow.com/questions/2378379/how-to-check-apartment-state-of-current-thread

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!