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.SourceToMatHostWait Class Reference

Host message-loop wait loop for SourceToMat grabber Open waits. More...

Static Public Member Functions

static Task< bool > WaitUntilOnHostLoopAsync (Func< bool > predicate, InitTimeoutBudget budget, CancellationToken userToken, SynchronizationContext hostLoopContext)
 Waits until predicate is true, pumping the host message loop each tick.
 
static async Task YieldHostLoopTickAsync (SynchronizationContext hostLoopContext, CancellationToken userToken)
 Yields one host-loop tick under SourceToMatSynchronizationContextScope.
 

Detailed Description

Host message-loop wait loop for SourceToMat grabber Open waits.

Host-loop implementation of the wait loop contract in SourceToMatWait (timeout is InitTimeoutBudget.IsExpired; user CancellationToken is cooperative cancellation only). Do not use InitTimeoutBudget.Token as a timeout signal.

Each tick restores the captured SynchronizationContext with SourceToMatSynchronizationContextScope and then calls SourceToMatHostMarshaling.YieldCapturedSynchronizationContextAsync. Nested scopes are supported, so WaitUntilOnHostLoopAsync may be called from inside an Open SourceToMatSynchronizationContextScope.

Prefer WaitUntilOnHostLoopAsync over a hand-written while around SourceToMatHostMarshaling.YieldCapturedSynchronizationContextAsync.

Event-based waits may use TaskCompletionSource<TResult> and CancellationToken.Register on the user token. Drive the outer wait with WaitUntilOnHostLoopAsync on tcs.Task.IsCompleted. When the budget expires, call TrySetCanceled on the source; do not rely on CancelAfter to unblock the wait.

Member Function Documentation

◆ WaitUntilOnHostLoopAsync()

static Task< bool > OpenCVForUnity.Extensions.SourceToMat.SourceToMatHostWait.WaitUntilOnHostLoopAsync ( Func< bool > predicate,
InitTimeoutBudget budget,
CancellationToken userToken,
SynchronizationContext hostLoopContext )
static

Waits until predicate is true, pumping the host message loop each tick.

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.
hostLoopContextCaptured SynchronizationContext from SourceToMatHostMarshaling.ResolveCapturedSynchronizationContext; may be null.
Returns
true when predicate became true; false when InitTimeoutBudget.IsExpired became true.
Exceptions
ArgumentNullExceptionThrown when predicate or budget is null.
OperationCanceledExceptionThrown when userToken is canceled.

◆ YieldHostLoopTickAsync()

static async Task OpenCVForUnity.Extensions.SourceToMat.SourceToMatHostWait.YieldHostLoopTickAsync ( SynchronizationContext hostLoopContext,
CancellationToken userToken )
static

Yields one host-loop tick under SourceToMatSynchronizationContextScope.

Used by WaitUntilOnHostLoopAsync. Call directly only when a single host-loop tick is required (for example to resume the loop after ConfigureAwait(false)) and a predicate wait is not appropriate. Polling loops should use WaitUntilOnHostLoopAsync.

Parameters
hostLoopContextCaptured SynchronizationContext for the yield; may be null.
userTokenCooperative user cancellation token.
Returns
A task that completes after one host-loop continuation.

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