public static AsyncStepSynchronizationContext InstallNew() { var ctx = new AsyncStepSynchronizationContext(Current ?? new SynchronizationContext()); SetSynchronizationContext(ctx); return(ctx); }
private async Task <CompositeStepContext> InvokeStepMethodAsync() { CompositeStepContext result; var ctx = AsyncStepSynchronizationContext.InstallNew(); try { result = await _stepInvocation.Invoke(Context, PrepareParameters()); VerifyParameters(); } catch (Exception e) { if (ScenarioExecutionException.TryWrap(e, out var wrapped)) { throw wrapped; } throw; } finally { UpdateNameDetails(); ctx.RestoreOriginal(); await ctx.WaitForTasksAsync(); } return(result); }
private async Task RunStepAsync() { IStepResultDescriptor result; var ctx = AsyncStepSynchronizationContext.InstallNew(); try { var args = PrepareArguments(); result = await _invocation.Invoke(Context, args); VerifyArguments(); } catch (Exception e) { if (ScenarioExecutionException.TryWrap(e, out var wrapped)) { throw wrapped; } throw; } finally { UpdateNameDetails(); ctx.RestoreOriginal(); await ctx.WaitForTasksAsync(); } await InvokeSubStepsAsync(result); }
private async Task TimeMeasuredInvokeAsync() { var watch = ExecutionTimeWatch.StartNew(); var ctx = AsyncStepSynchronizationContext.InstallNew(); try { try { await _stepInvocation.Invoke(_scenarioContext, PrepareParameters()); } finally { ctx.RestoreOriginal(); await ctx.WaitForTasksAsync(); } } finally { _result.SetExecutionTime(watch.GetTime()); } }
public RunWithSelfDelegate(SendOrPostCallback callback, AsyncStepSynchronizationContext context) { _callback = callback; _context = context; }