public static async Task <TResult> InvokeAsync <TCtxState, TResult>(this IStatefulSynchronizationContext <TCtxState> syncCtx, Func <StatefulSynchronizationContextInvokeArgs <TCtxState, Nil>, TResult> func, CancellationToken ct = default) { syncCtx.EnsureNotNull(nameof(syncCtx)); func.EnsureNotNull(nameof(func)); // return(await syncCtx.ExecuteAsync(func : execute, state : Nil.Value, ct : ct).ConfigureAwait(false)); // TResult execute(IStatefulSynchronizationContext <TCtxState> locSyncCtx, IVh <TCtxState> locSyncCtxState, Nil locState, CancellationToken locCt) => func(arg: new StatefulSynchronizationContextInvokeArgs <TCtxState, Nil>(syncCtx: locSyncCtx, syncCtxState: locSyncCtxState.Value, state: Nil.Value, ct: locCt)); }
public static async Task InvokeAsync <TCtxState, TState>(this IStatefulSynchronizationContext <TCtxState> syncCtx, Action <StatefulSynchronizationContextInvokeArgs <TCtxState, TState> > action, TState state, CancellationToken ct = default) { syncCtx.EnsureNotNull(nameof(syncCtx)); action.EnsureNotNull(nameof(action)); // await syncCtx.ExecuteAsync(func : execute, state : state, ct : ct).ConfigureAwait(false); // Nil execute(IStatefulSynchronizationContext <TCtxState> locSyncCtx, IVh <TCtxState> locSyncCtxState, TState locState, CancellationToken locCt) { action(obj: new StatefulSynchronizationContextInvokeArgs <TCtxState, TState>(syncCtx: locSyncCtx, syncCtxState: locSyncCtxState.Value, state: locState, ct: locCt)); return(Nil.Value); } }