Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check apartment state of current thread?

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?

like image 747
stiank81 Avatar asked Mar 04 '10 10:03

stiank81


2 Answers

System.Threading.Thread.CurrentThread.GetApartmentState()
like image 181
Marek Avatar answered Nov 02 '22 07:11

Marek


Use this or a similar method inside the function:

System.Threading.Thread.CurrentThread.GetApartmentState
like image 6
M.A. Hanin Avatar answered Nov 02 '22 05:11

M.A. Hanin