/// <summary> /// Creates a new Composer, which can be used to compose a task chain, which can be added to an /// existing composer as a single task. Note that this executes on the task chain, and not immediately. /// </summary> /// <typeparam name="T">The payload type</typeparam> /// <param name="compensation">The compensation</param> /// <param name="callback"></param> /// <returns></returns> public static CompensationResult <T> ComposeTask <T>(this Compensation <T> compensation, Action <Composer> callback) { return(compensation.Task(ComposeCompensationTask(compensation.Payload, callback, compensation.CancellationToken))); }
CompensationResult Compensation.Task(Task task) { return(new CompensationResultProxy <T>(_compensation.Task(task .ContinueWith(_ => _compensation.Payload, TaskContinuationOptions.ExecuteSynchronously)))); }
/// <summary> /// Creates a new Composer, which can be used to compose a task chain, which can be added to an /// existing composer as a single task. Note that this executes on the task chain, and not immediately. /// </summary> /// <param name="compensation"></param> /// <param name="callback"></param> /// <returns></returns> public static CompensationResult ComposeTask(this Compensation compensation, Action <Composer> callback) { return(compensation.Task(ComposerFactory.Compose(callback, compensation.CancellationToken))); }