mscorlib 4.0.0.0 System.SystemException System.Runtime.CompilerServices.TypeForwardedFrom("System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089") System.Runtime.InteropServices.ComVisible(false)

The count on a semaphore is decremented each time a thread enters the semaphore, and incremented when a thread releases the semaphore. When the count is zero, subsequent requests block until other threads release the semaphore. When all threads have released the semaphore, the count is at the maximum value specified when the semaphore was created. If a programming error causes a thread to call the method at this point, a is thrown.

The class does not enforce thread identity on calls to the and methods. It is not necessary for the same thread that called to call .

does not necessarily indicate a problem with the code where the exception occurred. Consider the following scenario: Thread A and thread B enter a semaphore that has a maximum count of two. A programming error in thread B causes it to call twice, so that the count on the semaphore is full. As a result, when thread A eventually calls , a is thrown.

For a list of initial property values for an instance of the class, see the constructor.

The exception that is thrown when the method is called on a semaphore whose count is already at the maximum.

- Constructor
  4.0.0.0

  This constructor initializes the property of the new instance to a system-supplied message that describes the error, such as "Adding the given count to the semaphore would cause it to exceed its maximum count." This message takes into account the current system culture.

  The following table shows the initial property values for an instance of the class.

  Property

  Value

  null.

  The system-supplied error message string.

  Initializes a new instance of the class with default values.

- Constructor
  4.0.0.0

  The content of is a text string intended to inform the user about the exception. The caller of this constructor is required to ensure that this string has been localized for the current system culture.

  The following table shows the initial property values for an instance of the class initialized with this constructor.

  Property

  Value

  null.

  .

  Initializes a new instance of the class with a specified error message.

  The error message that explains the reason for the exception.
- Constructor
  4.0.0.0

  This constructor is called during deserialization to reconstitute the exception object transmitted over a stream. For more information, see XML and SOAP Serialization.

  Initializes a new instance of the class with serialized data.

  The object that holds the serialized object data about the exception being thrown.
  The object that contains contextual information about the source or destination.
- Constructor
  4.0.0.0

  An exception that is thrown as a direct result of a previous exception should include a reference to the previous exception in the property. The property returns the same value that is passed into the constructor, or null if the property does not supply the inner exception value to the constructor.

  Initializes a new instance of the class with a specified error message and a reference to the inner exception that is the cause of this exception.

  The error message that explains the reason for the exception.
  The exception that is the cause of the current exception. If the parameter is not null, the current exception is raised in a catch block that handles the inner exception.