/// <summary> /// Resolve task safe /// </summary> private void InitNextTask() { //try get next task try { IPandaTask continuationPandaTask = _nextActionDelegate(); //no task resolved if (continuationPandaTask != null) { _state = ContinuationTaskState.WaitSecondComplete; continuationPandaTask.Done(HandleTaskCompleted).Fail(HandleTaskFailed); } else { RejectInternal(new NullReferenceException(@"Continuation callback returns null task!")); } } catch (Exception ex) { if (Status != PandaTaskStatus.Pending) { throw; } //reject on non system exceptions RejectInternal(ex); } }
/// <summary> /// Reject Task with state change /// </summary> /// <param name="exception">reject exception</param> private void RejectInternal(Exception exception) { _state = ContinuationTaskState.Completed; Reject(exception); }
public override void Dispose() { //to prevent supported state after dispose _state = ContinuationTaskState.Completed; base.Dispose(); }
/// <summary> /// Set task resolved /// </summary> private void ResolveInternal() { //if continuation task completed _state = ContinuationTaskState.Completed; base.Resolve(); }