public static async Task GenerateStageAsync( this IStageGenerator stageGenerator, IStageSeed stageSeed, CancellationToken cancellation) { Contracts.Requires.That(stageGenerator != null); Contracts.Requires.That(stageSeed != null); using (stageSeed.LinkCancellation(cancellation)) { await stageGenerator.GenerateStageAsync(stageSeed).DontMarshallContext(); } }
private async Task HandleStageSeed(IStageSeed seed) { Contracts.Requires.That(seed != null); try { using (seed.LinkCancellation(this.CancellationToken)) using (seed.Progress.WrapExceptions(error => Wrap(seed, error)).Subscribe(this.progress.OnNext)) { await seed.CompleteAndAwaitAsync().DontMarshallContext(); } } catch (Exception) { // if generation fails just end the task early in a successfully completed state so that the // action block keeps on processing additional stage generation requests instead of faulting } }