mscorlib(4.0.0.0) API with additions
|
Limits the number of threads that can access a resource or pool of resources concurrently. More...
Public Member Functions | |
Semaphore (int initialCount, int maximumCount) | |
Initializes a new instance of the T:System.Threading.Semaphore class, specifying the initial number of entries and the maximum number of concurrent entries. More... | |
Semaphore (int initialCount, int maximumCount, string name) | |
Initializes a new instance of the T:System.Threading.Semaphore class, specifying the initial number of entries and the maximum number of concurrent entries, and optionally specifying the name of a system semaphore object. More... | |
Semaphore (int initialCount, int maximumCount, string name, out bool createdNew) | |
Initializes a new instance of the T:System.Threading.Semaphore class, specifying the initial number of entries and the maximum number of concurrent entries, optionally specifying the name of a system semaphore object, and specifying a variable that receives a value indicating whether a new system semaphore was created. More... | |
unsafe | Semaphore (int initialCount, int maximumCount, string name, out bool createdNew, SemaphoreSecurity semaphoreSecurity) |
Initializes a new instance of the T:System.Threading.Semaphore class, specifying the initial number of entries and the maximum number of concurrent entries, optionally specifying the name of a system semaphore object, specifying a variable that receives a value indicating whether a new system semaphore was created, and specifying security access control for the system semaphore. More... | |
int | Release () |
Exits the semaphore and returns the previous count. More... | |
int | Release (int releaseCount) |
Exits the semaphore a specified number of times and returns the previous count. More... | |
SemaphoreSecurity | GetAccessControl () |
Gets the access control security for a named system semaphore. More... | |
void | SetAccessControl (SemaphoreSecurity semaphoreSecurity) |
Sets the access control security for a named system semaphore. More... | |
![]() | |
virtual bool | WaitOne (int millisecondsTimeout, bool exitContext) |
Blocks the current thread until the current T:System.Threading.WaitHandle receives a signal, using a 32-bit signed integer to specify the time interval and specifying whether to exit the synchronization domain before the wait. More... | |
virtual bool | WaitOne (TimeSpan timeout, bool exitContext) |
Blocks the current thread until the current instance receives a signal, using a T:System.TimeSpan to specify the time interval and specifying whether to exit the synchronization domain before the wait. More... | |
virtual bool | WaitOne () |
Blocks the current thread until the current T:System.Threading.WaitHandle receives a signal. More... | |
virtual bool | WaitOne (int millisecondsTimeout) |
Blocks the current thread until the current T:System.Threading.WaitHandle receives a signal, using a 32-bit signed integer to specify the time interval in milliseconds. More... | |
virtual bool | WaitOne (TimeSpan timeout) |
Blocks the current thread until the current instance receives a signal, using a T:System.TimeSpan to specify the time interval. More... | |
virtual void | Close () |
Releases all resources held by the current T:System.Threading.WaitHandle. More... | |
void | Dispose () |
Releases all resources used by the current instance of the T:System.Threading.WaitHandle class. More... | |
![]() | |
object | GetLifetimeService () |
Retrieves the current lifetime service object that controls the lifetime policy for this instance. More... | |
virtual object | InitializeLifetimeService () |
Obtains a lifetime service object to control the lifetime policy for this instance. More... | |
virtual ObjRef | CreateObjRef (Type requestedType) |
Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object. More... | |
Static Public Member Functions | |
static Semaphore | OpenExisting (string name) |
Opens the specified named semaphore, if it already exists. More... | |
static Semaphore | OpenExisting (string name, SemaphoreRights rights) |
Opens the specified named semaphore, if it already exists, with the desired security access. More... | |
static bool | TryOpenExisting (string name, out Semaphore result) |
Opens the specified named semaphore, if it already exists, and returns a value that indicates whether the operation succeeded. More... | |
static bool | TryOpenExisting (string name, SemaphoreRights rights, out Semaphore result) |
Opens the specified named semaphore, if it already exists, with the desired security access, and returns a value that indicates whether the operation succeeded. More... | |
![]() | |
static bool | WaitAll (WaitHandle[] waitHandles, int millisecondsTimeout, bool exitContext) |
Waits for all the elements in the specified array to receive a signal, using an T:System.Int32 value to specify the time interval and specifying whether to exit the synchronization domain before the wait. More... | |
static bool | WaitAll (WaitHandle[] waitHandles, TimeSpan timeout, bool exitContext) |
Waits for all the elements in the specified array to receive a signal, using a T:System.TimeSpan value to specify the time interval, and specifying whether to exit the synchronization domain before the wait. More... | |
static bool | WaitAll (WaitHandle[] waitHandles) |
Waits for all the elements in the specified array to receive a signal. More... | |
static bool | WaitAll (WaitHandle[] waitHandles, int millisecondsTimeout) |
Waits for all the elements in the specified array to receive a signal, using an T:System.Int32 value to specify the time interval. More... | |
static bool | WaitAll (WaitHandle[] waitHandles, TimeSpan timeout) |
Waits for all the elements in the specified array to receive a signal, using a T:System.TimeSpan value to specify the time interval. More... | |
static int | WaitAny (WaitHandle[] waitHandles, int millisecondsTimeout, bool exitContext) |
Waits for any of the elements in the specified array to receive a signal, using a 32-bit signed integer to specify the time interval, and specifying whether to exit the synchronization domain before the wait. More... | |
static int | WaitAny (WaitHandle[] waitHandles, TimeSpan timeout, bool exitContext) |
Waits for any of the elements in the specified array to receive a signal, using a T:System.TimeSpan to specify the time interval and specifying whether to exit the synchronization domain before the wait. More... | |
static int | WaitAny (WaitHandle[] waitHandles, TimeSpan timeout) |
Waits for any of the elements in the specified array to receive a signal, using a T:System.TimeSpan to specify the time interval. More... | |
static int | WaitAny (WaitHandle[] waitHandles) |
Waits for any of the elements in the specified array to receive a signal. More... | |
static int | WaitAny (WaitHandle[] waitHandles, int millisecondsTimeout) |
Waits for any of the elements in the specified array to receive a signal, using a 32-bit signed integer to specify the time interval. More... | |
static bool | SignalAndWait (WaitHandle toSignal, WaitHandle toWaitOn) |
Signals one T:System.Threading.WaitHandle and waits on another. More... | |
static bool | SignalAndWait (WaitHandle toSignal, WaitHandle toWaitOn, TimeSpan timeout, bool exitContext) |
Signals one T:System.Threading.WaitHandle and waits on another, specifying the time-out interval as a T:System.TimeSpan and specifying whether to exit the synchronization domain for the context before entering the wait. More... | |
static bool | SignalAndWait (WaitHandle toSignal, WaitHandle toWaitOn, int millisecondsTimeout, bool exitContext) |
Signals one T:System.Threading.WaitHandle and waits on another, specifying a time-out interval as a 32-bit signed integer and specifying whether to exit the synchronization domain for the context before entering the wait. More... | |
Additional Inherited Members | |
![]() | |
const int | WaitTimeout = 258 |
Indicates that a M:System.Threading.WaitHandle.WaitAny(System.Threading.WaitHandle[],System.Int32,System.Boolean) operation timed out before any of the wait handles were signaled. This field is constant. More... | |
![]() | |
WaitHandle () | |
Initializes a new instance of the T:System.Threading.WaitHandle class. More... | |
virtual void | Dispose (bool explicitDisposing) |
When overridden in a derived class, releases the unmanaged resources used by the T:System.Threading.WaitHandle, and optionally releases the managed resources. More... | |
![]() | |
MarshalByRefObject | MemberwiseClone (bool cloneIdentity) |
Creates a shallow copy of the current T:System.MarshalByRefObject object. More... | |
![]() | |
static readonly IntPtr | InvalidHandle = GetInvalidHandle() |
Represents an invalid native operating system handle. This field is read-only. More... | |
![]() | |
virtual IntPtr | Handle [get, set] |
Gets or sets the native operating system handle. More... | |
SafeWaitHandle | SafeWaitHandle [get, set] |
Gets or sets the native operating system handle. More... | |
Limits the number of threads that can access a resource or pool of resources concurrently.
Definition at line 16 of file Semaphore.cs.
System.Threading.Semaphore.Semaphore | ( | int | initialCount, |
int | maximumCount | ||
) |
Initializes a new instance of the T:System.Threading.Semaphore class, specifying the initial number of entries and the maximum number of concurrent entries.
initialCount | The initial number of requests for the semaphore that can be granted concurrently. |
maximumCount | The maximum number of requests for the semaphore that can be granted concurrently. |
T:System.ArgumentException | initialCount is greater than maximumCount . |
T:System.ArgumentOutOfRangeException | maximumCount is less than 1.-or- initialCount is less than 0. |
Definition at line 38 of file Semaphore.cs.
System.Threading.Semaphore.Semaphore | ( | int | initialCount, |
int | maximumCount, | ||
string | name | ||
) |
Initializes a new instance of the T:System.Threading.Semaphore class, specifying the initial number of entries and the maximum number of concurrent entries, and optionally specifying the name of a system semaphore object.
initialCount | The initial number of requests for the semaphore that can be granted concurrently. |
maximumCount | The maximum number of requests for the semaphore that can be granted concurrently. |
name | The name of a named system semaphore object. |
T:System.ArgumentException | initialCount is greater than maximumCount .-or- name is longer than 260 characters. |
T:System.ArgumentOutOfRangeException | maximumCount is less than 1.-or- initialCount is less than 0. |
T:System.IO.IOException | A Win32 error occurred. |
T:System.UnauthorizedAccessException | The named semaphore exists and has access control security, and the user does not have F:System.Security.AccessControl.SemaphoreRights.FullControl. |
T:System.Threading.WaitHandleCannotBeOpenedException | The named semaphore cannot be created, perhaps because a wait handle of a different type has the same name. |
Definition at line 58 of file Semaphore.cs.
System.Threading.Semaphore.Semaphore | ( | int | initialCount, |
int | maximumCount, | ||
string | name, | ||
out bool | createdNew | ||
) |
Initializes a new instance of the T:System.Threading.Semaphore class, specifying the initial number of entries and the maximum number of concurrent entries, optionally specifying the name of a system semaphore object, and specifying a variable that receives a value indicating whether a new system semaphore was created.
initialCount | The initial number of requests for the semaphore that can be satisfied concurrently. |
maximumCount | The maximum number of requests for the semaphore that can be satisfied concurrently. |
name | The name of a named system semaphore object. |
createdNew | When this method returns, contains true if a local semaphore was created (that is, if name is null or an empty string) or if the specified named system semaphore was created; false if the specified named system semaphore already existed. This parameter is passed uninitialized. |
T:System.ArgumentException | initialCount is greater than maximumCount . -or- name is longer than 260 characters. |
T:System.ArgumentOutOfRangeException | maximumCount is less than 1.-or- initialCount is less than 0. |
T:System.IO.IOException | A Win32 error occurred. |
T:System.UnauthorizedAccessException | The named semaphore exists and has access control security, and the user does not have F:System.Security.AccessControl.SemaphoreRights.FullControl. |
T:System.Threading.WaitHandleCannotBeOpenedException | The named semaphore cannot be created, perhaps because a wait handle of a different type has the same name. |
Definition at line 105 of file Semaphore.cs.
unsafe System.Threading.Semaphore.Semaphore | ( | int | initialCount, |
int | maximumCount, | ||
string | name, | ||
out bool | createdNew, | ||
SemaphoreSecurity | semaphoreSecurity | ||
) |
Initializes a new instance of the T:System.Threading.Semaphore class, specifying the initial number of entries and the maximum number of concurrent entries, optionally specifying the name of a system semaphore object, specifying a variable that receives a value indicating whether a new system semaphore was created, and specifying security access control for the system semaphore.
initialCount | The initial number of requests for the semaphore that can be satisfied concurrently. |
maximumCount | The maximum number of requests for the semaphore that can be satisfied concurrently. |
name | The name of a named system semaphore object. |
createdNew | When this method returns, contains true if a local semaphore was created (that is, if name is null or an empty string) or if the specified named system semaphore was created; false if the specified named system semaphore already existed. This parameter is passed uninitialized. |
semaphoreSecurity | A T:System.Security.AccessControl.SemaphoreSecurity object that represents the access control security to be applied to the named system semaphore. |
T:System.ArgumentException | initialCount is greater than maximumCount .-or- name is longer than 260 characters. |
T:System.ArgumentOutOfRangeException | maximumCount is less than 1.-or- initialCount is less than 0. |
T:System.UnauthorizedAccessException | The named semaphore exists and has access control security, and the user does not have F:System.Security.AccessControl.SemaphoreRights.FullControl. |
T:System.IO.IOException | A Win32 error occurred. |
T:System.Threading.WaitHandleCannotBeOpenedException | The named semaphore cannot be created, perhaps because a wait handle of a different type has the same name. |
Definition at line 126 of file Semaphore.cs.
SemaphoreSecurity System.Threading.Semaphore.GetAccessControl | ( | ) |
Gets the access control security for a named system semaphore.
T:System.UnauthorizedAccessException | The current T:System.Threading.Semaphore object represents a named system semaphore, and the user does not have F:System.Security.AccessControl.SemaphoreRights.ReadPermissions rights.-or-The current T:System.Threading.Semaphore object represents a named system semaphore and was not opened with F:System.Security.AccessControl.SemaphoreRights.ReadPermissions rights. |
T:System.NotSupportedException | Not supported for Windows 98 or Windows Millennium Edition. |
Definition at line 344 of file Semaphore.cs.
|
static |
Opens the specified named semaphore, if it already exists.
name | The name of the system semaphore to open. |
T:System.ArgumentException | name is an empty string.-or- name is longer than 260 characters. |
T:System.ArgumentNullException | name is null . |
T:System.Threading.WaitHandleCannotBeOpenedException | The named semaphore does not exist. |
T:System.IO.IOException | A Win32 error occurred. |
T:System.UnauthorizedAccessException | The named semaphore exists, but the user does not have the security access required to use it. |
Definition at line 193 of file Semaphore.cs.
|
static |
Opens the specified named semaphore, if it already exists, with the desired security access.
name | The name of the system semaphore to open. |
rights | A bitwise combination of the enumeration values that represent the desired security access. |
T:System.ArgumentException | name is an empty string.-or- name is longer than 260 characters. |
T:System.ArgumentNullException | name is null . |
T:System.Threading.WaitHandleCannotBeOpenedException | The named semaphore does not exist. |
T:System.IO.IOException | A Win32 error occurred. |
T:System.UnauthorizedAccessException | The named semaphore exists, but the user does not have the desired security access rights. |
Definition at line 211 of file Semaphore.cs.
int System.Threading.Semaphore.Release | ( | ) |
Exits the semaphore and returns the previous count.
T:System.Threading.SemaphoreFullException | The semaphore count is already at the maximum value. |
T:System.IO.IOException | A Win32 error occurred with a named semaphore. |
T:System.UnauthorizedAccessException | The current semaphore represents a named system semaphore, but the user does not have F:System.Security.AccessControl.SemaphoreRights.Modify.-or-The current semaphore represents a named system semaphore, but it was not opened with F:System.Security.AccessControl.SemaphoreRights.Modify. |
Definition at line 312 of file Semaphore.cs.
int System.Threading.Semaphore.Release | ( | int | releaseCount | ) |
Exits the semaphore a specified number of times and returns the previous count.
releaseCount | The number of times to exit the semaphore. |
T:System.ArgumentOutOfRangeException | releaseCount is less than 1. |
T:System.Threading.SemaphoreFullException | The semaphore count is already at the maximum value. |
T:System.IO.IOException | A Win32 error occurred with a named semaphore. |
T:System.UnauthorizedAccessException | The current semaphore represents a named system semaphore, but the user does not have F:System.Security.AccessControl.SemaphoreRights.Modify rights.-or-The current semaphore represents a named system semaphore, but it was not opened with F:System.Security.AccessControl.SemaphoreRights.Modify rights. |
Definition at line 327 of file Semaphore.cs.
void System.Threading.Semaphore.SetAccessControl | ( | SemaphoreSecurity | semaphoreSecurity | ) |
Sets the access control security for a named system semaphore.
semaphoreSecurity | A T:System.Security.AccessControl.SemaphoreSecurity object that represents the access control security to be applied to the named system semaphore. |
T:System.ArgumentNullException | semaphoreSecurity is null . |
T:System.UnauthorizedAccessException | The user does not have F:System.Security.AccessControl.SemaphoreRights.ChangePermissions rights.-or-The semaphore was not opened with F:System.Security.AccessControl.SemaphoreRights.ChangePermissions rights. |
T:System.NotSupportedException | The current T:System.Threading.Semaphore object does not represent a named system semaphore. |
Definition at line 355 of file Semaphore.cs.
|
static |
Opens the specified named semaphore, if it already exists, and returns a value that indicates whether the operation succeeded.
name | The name of the system semaphore to open. |
result | When this method returns, contains a T:System.Threading.Semaphore object that represents the named semaphore if the call succeeded, or null if the call failed. This parameter is treated as uninitialized. |
true
if the named semaphore was opened successfully; otherwise, false
.T:System.ArgumentException | name is an empty string.-or- name is longer than 260 characters. |
T:System.ArgumentNullException | name is null . |
T:System.IO.IOException | A Win32 error occurred. |
T:System.UnauthorizedAccessException | The named semaphore exists, but the user does not have the security access required to use it. |
Definition at line 242 of file Semaphore.cs.
|
static |
Opens the specified named semaphore, if it already exists, with the desired security access, and returns a value that indicates whether the operation succeeded.
name | The name of the system semaphore to open. |
rights | A bitwise combination of the enumeration values that represent the desired security access. |
result | When this method returns, contains a T:System.Threading.Semaphore object that represents the named semaphore if the call succeeded, or null if the call failed. This parameter is treated as uninitialized. |
true
if the named semaphore was opened successfully; otherwise, false
.T:System.ArgumentException | name is an empty string.-or- name is longer than 260 characters. |
T:System.ArgumentNullException | name is null . |
T:System.IO.IOException | A Win32 error occurred. |
T:System.UnauthorizedAccessException | The named semaphore exists, but the user does not have the security access required to use it. |
Definition at line 261 of file Semaphore.cs.