Returns an ApartmentState value indicating the apartment state.
Assembly: mscorlib (in mscorlib.dll)
The following code example demonstrates the , SetApartmentState, and TrySetApartmentState methods. The code example creates a thread. Before the thread is started, displays the initial ApartmentState.Unknown state and SetApartmentState changes the state to ApartmentState.STA. The TrySetApartmentState method then returns false when attempting to change the state to ApartmentState.MTA because the apartment state is already set. If the same operation had been attempted with SetApartmentState, InvalidOperationException would have been thrown.
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.