如何检查当前线程的单元状态? [英] How to check apartment state of current thread?

查看:241
本文介绍了如何检查当前线程的单元状态?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个功能,它要求将在STA公寓状态下运行。我wan't检查它是否正在运行的STA,如果没有产卵它运行在STA一个新的线程。

我怎么能检查哪些单元状态当前线程正在运行?

解决方案

  System.Threading.Thread.CurrentThread.GetApartmentState()
 

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()

这篇关于如何检查当前线程的单元状态?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆