如何检查当前线程的公寓状态?

我有一个需要在STA公寓状态下运行的function。 我不想检查它是否作为STA运行,如果没有生成一个在STA中运行的新线程。

如何检查当前线程运行的公寓状态?

System.Threading.Thread.CurrentThread.GetApartmentState() 

在函数内使用此方法或类似方法:

 System.Threading.Thread.CurrentThread.GetApartmentState