Class BlockingOperations
Inherited Members
Namespace: DotNext.Threading
Assembly: DotNext.dll
Syntax
public static class BlockingOperations
Methods
View SourceJoin(Thread, TimeSpan, CancellationToken, bool)
Blocks the calling thread until the thread terminates, or the specified time elapses, or the token turns into canceled state.
Declaration
public static bool Join(this Thread thread, TimeSpan timeout, CancellationToken token, bool throwOnCancellation = false)
Parameters
| Type | Name | Description |
|---|---|---|
| Thread | thread | The thread instance. |
| TimeSpan | timeout | The time to wait. |
| CancellationToken | token | The token that can be used to cancel the operation. |
| bool | throwOnCancellation | true to throw OperationCanceledException if |
Returns
| Type | Description |
|---|---|
| bool | true if the thread stops successfully; false if timeout occurred or |
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException |
|
| OperationCanceledException |
|
TryEnter(Lock, TimeSpan, CancellationToken, bool)
Tries to acquire an exclusive lock on the specified object with cancellation support.
Declaration
public static bool TryEnter(this Lock @lock, TimeSpan timeout, CancellationToken token, bool throwOnCancellation = false)
Parameters
| Type | Name | Description |
|---|---|---|
| Lock | lock | The object on which to acquire the lock. |
| TimeSpan | timeout | Time to wait for the lock. |
| CancellationToken | token | The token that can be used to cancel the operation. |
| bool | throwOnCancellation | true to throw OperationCanceledException if |
Returns
| Type | Description |
|---|---|
| bool | true if the lock is acquired successfully; false if timeout occurred or |
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException |
|
| OperationCanceledException |
|