public Task ServerMethodThatReturnsCustomTask() { var result = new CustomTask(); result.Start(); return(result); }
public CustomTask ReturnsCustomTask() { _workload.BeforeReturningAwaitable(); _workload.BeforeReturningAwaiter(); var task = new CustomTask(() => _workload.GetResult()); if (_workload.IsCompleted) { task.Start(); } else { _workload.OnCompleted(task.Start); } return(task); }
static void Main(string[] args) { CustomTask antecedent = new CustomTask( () => { throw new Exception("Unhandled"); }); antecedent.ContinueWith( (predTask) => { ((CustomTask)predTask).PerformRollback(); }, TaskContinuationOptions.OnlyOnFaulted); antecedent.Start(); try { antecedent.Wait(); } catch (AggregateException ex) { } }