public:
bool Wait(TimeSpan timeout, System::Threading::CancellationToken cancellationToken);
public bool Wait(TimeSpan timeout, System.Threading.CancellationToken cancellationToken);
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public bool Wait(TimeSpan timeout, System.Threading.CancellationToken cancellationToken);
member this.Wait : TimeSpan * System.Threading.CancellationToken -> bool
[<System.Runtime.Versioning.UnsupportedOSPlatform("browser")>]
member this.Wait : TimeSpan * System.Threading.CancellationToken -> bool
Public Function Wait (timeout As TimeSpan, cancellationToken As CancellationToken) As Boolean
Parameters
A TimeSpan that represents the number of milliseconds to wait, a TimeSpan that represents -1 milliseconds to wait indefinitely, or a TimeSpan that represents 0 milliseconds to test the wait handle and return immediately.
Returnstrue
if the current thread successfully entered the SemaphoreSlim; otherwise, false
.
cancellationToken
was canceled.
timeout
is a negative number other than -1, which represents an infinite timeout.
-or-
In .NET 9 and earlier versions, timeout
is greater than Int32.MaxValue.
The semaphoreSlim instance has been disposed.
-or-
The CancellationTokenSource that created cancellationToken
has already been disposed.
If the timeout is set to -1 milliseconds, the method waits indefinitely.
If the timeout is set to zero milliseconds, the method doesn't block. It tests the state of the wait handle and returns immediately.
If a thread or task is able to enter the semaphore, it decrements the CurrentCount property by one.
If cancellationToken
is cancelled, or if a thread or task is blocked when calling Wait(TimeSpan, CancellationToken) and the timeout interval specified by millisecondsTimeout
expires:
If cancellationToken
is cancelled, the method throws an OperationCanceledException exception.
Blocks the current thread until it can enter the SemaphoreSlim, using a 32-bit signed integer that specifies the timeout, while observing a CancellationToken.
public:
bool Wait(int millisecondsTimeout, System::Threading::CancellationToken cancellationToken);
public bool Wait(int millisecondsTimeout, System.Threading.CancellationToken cancellationToken);
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public bool Wait(int millisecondsTimeout, System.Threading.CancellationToken cancellationToken);
member this.Wait : int * System.Threading.CancellationToken -> bool
[<System.Runtime.Versioning.UnsupportedOSPlatform("browser")>]
member this.Wait : int * System.Threading.CancellationToken -> bool
Public Function Wait (millisecondsTimeout As Integer, cancellationToken As CancellationToken) As Boolean
Parameters
The number of milliseconds to wait, Infinite (-1) to wait indefinitely, or zero to test the state of the wait handle and return immediately.
Returnstrue
if the current thread successfully entered the SemaphoreSlim; otherwise, false
.
cancellationToken
was canceled.
millisecondsTimeout
is a negative number other than -1, which represents an infinite timeout.
-or-
millisecondsTimeout
is greater than Int32.MaxValue.
If the timeout is set to -1 milliseconds, the method waits indefinitely.
If the timeout is set to zero milliseconds, the method doesn't block. It tests the state of the wait handle and returns immediately.
If a thread or task is able to enter the semaphore, it decrements the CurrentCount property by one.
If cancellationToken
is cancelled, or if a thread or task is blocked when calling Wait(Int32, CancellationToken) and the timeout interval specified by millisecondsTimeout
expires:
If cancellationToken
is cancelled, the method throws an OperationCanceledException exception.
public:
bool Wait(TimeSpan timeout);
public bool Wait(TimeSpan timeout);
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public bool Wait(TimeSpan timeout);
member this.Wait : TimeSpan -> bool
[<System.Runtime.Versioning.UnsupportedOSPlatform("browser")>]
member this.Wait : TimeSpan -> bool
Public Function Wait (timeout As TimeSpan) As Boolean
Parameters
A TimeSpan that represents the number of milliseconds to wait, a TimeSpan that represents -1 milliseconds to wait indefinitely, or a TimeSpan that represents 0 milliseconds to test the wait handle and return immediately.
Returnstrue
if the current thread successfully entered the SemaphoreSlim; otherwise, false
.
timeout
is a negative number other than -1, which represents an infinite timeout.
-or-
In .NET 9 and earlier versions, timeout
is greater than Int32.MaxValue.
The semaphoreSlim instance has been disposed.
RemarksIf the timeout is set to -1 milliseconds, the method waits indefinitely.
If the timeout is set to zero milliseconds, the method doesn't block. It tests the state of the wait handle and returns immediately.
If a thread or task is able to enter the semaphore, it decrements the CurrentCount property by one.
If a thread or task is blocked when calling Wait(TimeSpan) and the timeout interval specified by millisecondsTimeout
expires:
Blocks the current thread until it can enter the SemaphoreSlim, using a 32-bit signed integer that specifies the timeout.
public:
bool Wait(int millisecondsTimeout);
public bool Wait(int millisecondsTimeout);
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public bool Wait(int millisecondsTimeout);
member this.Wait : int -> bool
[<System.Runtime.Versioning.UnsupportedOSPlatform("browser")>]
member this.Wait : int -> bool
Public Function Wait (millisecondsTimeout As Integer) As Boolean
Parameters
The number of milliseconds to wait, Infinite (-1) to wait indefinitely, or zero to test the state of the wait handle and return immediately.
Returnstrue
if the current thread successfully entered the SemaphoreSlim; otherwise, false
.
millisecondsTimeout
is a negative number other than -1, which represents an infinite timeout -or- timeout is greater than Int32.MaxValue.
If the timeout is set to -1 milliseconds, the method waits indefinitely.
If the timeout is set to zero milliseconds, the method doesn't block. It tests the state of the wait handle and returns immediately.
If a thread or task is able to enter the semaphore, it decrements the CurrentCount property by one.
If a thread or task is blocked when calling Wait(Int32) and the timeout interval specified by millisecondsTimeout
expires:
public:
void Wait();
public void Wait();
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public void Wait();
member this.Wait : unit -> unit
[<System.Runtime.Versioning.UnsupportedOSPlatform("browser")>]
member this.Wait : unit -> unit
Public Sub Wait ()
The current instance has already been disposed.
RemarksIf a thread or task is able to enter the semaphore, it decrements the CurrentCount property by one.
See also Wait(CancellationToken)public:
void Wait(System::Threading::CancellationToken cancellationToken);
public void Wait(System.Threading.CancellationToken cancellationToken);
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public void Wait(System.Threading.CancellationToken cancellationToken);
member this.Wait : System.Threading.CancellationToken -> unit
[<System.Runtime.Versioning.UnsupportedOSPlatform("browser")>]
member this.Wait : System.Threading.CancellationToken -> unit
Public Sub Wait (cancellationToken As CancellationToken)
Parameters
cancellationToken
was canceled.
The current instance has already been disposed.
-or-
The CancellationTokenSource that created cancellationToken
has already been disposed.
If a thread or task is able to enter the semaphore, it decrements the CurrentCount property by one.
If cancellationToken
is cancelled, the thread or task doesn't enter the semaphore, and the CurrentCount property isn't decremented. Instead, the method throws an OperationCanceledException exception.
Collaborate with us on GitHub
The source for this content can be found on GitHub, where you can also create and review issues and pull requests. For more information, see our contributor guide. In this articleWas this page helpful?
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4