OpenCV for Unity 3.0.4
Enox Software / Please refer to OpenCV official document ( http://docs.opencv.org/5.0/index.html ) for the details of the argument of the method.
Loading...
Searching...
No Matches
OpenCVForUnity.Extensions.SourceToMat.SourceToMatWait Class Reference

Shared wait loop for SourceToMat initialization and first-frame waits. More...

Static Public Member Functions

static async Task< bool > WaitUntilAsync (Func< bool > predicate, InitTimeoutBudget budget, CancellationToken userToken, Func< CancellationToken, Task > yieldOneTickAsync)
 Waits until predicate is true, the budget expires, or userToken is canceled.
 

Detailed Description

Shared wait loop for SourceToMat initialization and first-frame waits.

Timeout is InitTimeoutBudget.IsExpired (stopwatch / wall-clock remaining budget). Do not use InitTimeoutBudget.Token as the loop condition, as a CancellationToken.Register timeout, or as the only CancellationToken.ThrowIfCancellationRequested deadline. InitTimeoutBudget.Token is cooperative user cancellation only. On some single-threaded hosts, time-based token cancellation such as CancellationTokenSource.CancelAfter does not fire, so a loop that waits only on that token never ends.

Loop contract:

  • While InitTimeoutBudget.IsExpired is false, throw if the user token is canceled, return true when the predicate is true, otherwise await one tick.
  • Return false when the budget expires before the predicate becomes true (timeout).
  • Throw OperationCanceledException when the user token is canceled.

The caller supplies yieldOneTickAsync: one scheduling step per loop iteration. Host integrations that must pump the main message loop should inject a tick that advances that loop. Callers already on a compatible SynchronizationContext may pass a delegate that awaits Task.Yield. Do not use Task.Delay (including a delay of zero) as the tick.

Member Function Documentation

◆ WaitUntilAsync()

static async Task< bool > OpenCVForUnity.Extensions.SourceToMat.SourceToMatWait.WaitUntilAsync ( Func< bool > predicate,
InitTimeoutBudget budget,
CancellationToken userToken,
Func< CancellationToken, Task > yieldOneTickAsync )
static

Waits until predicate is true, the budget expires, or userToken is canceled.

Parameters
predicateReturns true when the wait should complete. Must not be null.
budgetShared initialization timeout budget. Must not be null.
userTokenCooperative user cancellation token. Not a timeout signal.
yieldOneTickAsyncAwaits one scheduling tick per loop iteration. The host integration chooses whether that tick advances the main message loop or yields to the current SynchronizationContext (for example via Task.Yield). Must not be null.
Returns
true when predicate became true; false when InitTimeoutBudget.IsExpired became true.
Exceptions
ArgumentNullExceptionThrown when predicate , budget , or yieldOneTickAsync is null.
OperationCanceledExceptionThrown when userToken is canceled.

The documentation for this class was generated from the following file: