Gets or sets the apartment state of this thread.
[Visual Basic] Public Property ApartmentState As ApartmentState [C#] public ApartmentState ApartmentState {get; set;} [C++] public: __property ApartmentState get_ApartmentState(); public: __property void set_ApartmentState(ApartmentState); [JScript] public function get ApartmentState() : ApartmentState; public function set ApartmentState(ApartmentState);
One of the ApartmentState values. The initial value is Unknown.
Exception Type | Condition |
---|---|
ArgumentException | An attempt is made to set this property to a state that is not a valid apartment state (a state other than STA or MTA). |
A thread can be marked to indicate that it will execute in a single-threaded or multithreaded apartment. The property can be set when the thread is in the Unstarted or Running thread state; however, it can be set only once for a thread. If the property has not been set, it returns Unknown.
Thread Class | Thread Members | System.Threading Namespace | ThreadState