BCL mscorlib [00 00 00 00 00 00 00 00 04 00 00 00 00 00 00 00 ] 1.0.5000.0 2.0.0.0 4.0.0.0 All public static members of this type are safe for multithreaded operations. No instance members are guaranteed to be thread safe. System.SystemException

Represents errors that occur when a method is invoked on a and the thread is in a that is invalid for the method.

Once a thread is created, it is in one or more states, as defined by , until it terminates. is thrown by methods that cannot perform the requested operation due to the current state of a thread. For example, calling on a thread that has terminated results in a exception.

The following example demonstrates an error that causes a exception to be thrown.

`using System; using System.Threading; public class ThreadWork { public static void DoWork() { Console.WriteLine("Working thread..."); } } class ThreadStateTest{ public static void Main() { ThreadStart myThreadDelegate = new ThreadStart(ThreadWork.DoWork); Thread myThread = new Thread(myThreadDelegate); myThread.Start(); Thread.Sleep(0); Console.WriteLine("In main. Attempting to restart myThread."); try { myThread.Start(); } catch (ThreadStateException e) { Console.WriteLine("Caught: {0}", e.Message); } } }`

The output is

Working thread...

In main. Attempting to restart myThread.

Caught: Thread is running or terminated. Cannot restart.

- Constructor

  Constructs and initializes a new instance of the class.

  This constructor initializes the property of the new instance to a system-supplied message that describes the error, such as "The requested operation cannot be performed on the thread due to its current state." This message takes into account the current system culture.

  The property of the new instance is initialized to

  .

  0
  1.0.5000.0
  2.0.0.0
  4.0.0.0
- Constructor
  A that describes the error. The content of is intended to be understood by humans. The caller of this constructor is required to ensure that this string has been localized for the current system culture.

  Constructs and initializes a new instance of the class.

  This constructor initializes the property of the new instance using . If is , the property is initialized to the system-supplied message provided by the constructor that takes no arguments.

  The property of the new instance is initialized to .

  0
  1.0.5000.0
  2.0.0.0
  4.0.0.0
- Constructor
  To be added.
  To be added.
  To be added.
  To be added.
  1.0.5000.0
  2.0.0.0
  4.0.0.0
- Constructor
  A that describes the error. The content of is intended to be understood by humans. The caller of this constructor is required to ensure that this string has been localized for the current system culture.
  An instance of that is the cause of the current exception. If is non-null, then the current Exception was raised in a catch block handling

  Constructs and initializes a new instance of the class.

  This constructor initializes the property of the new instance using and the property using . If is , the property is initialized to the system-supplied message provided by the constructor that takes no arguments.

  For more information on inner exceptions, see .

  0
  1.0.5000.0
  2.0.0.0
  4.0.0.0
0 System.Runtime.InteropServices.ComVisible(true)