private Task<bool> ReadAsync_ReadAhead(Task task) { if (task.IsSuccess()) { _validationState = ValidatingReaderState.Read; return AsyncHelper.DoneTaskTrue; ; } else { return _ReadAsync_ReadAhead(task); } }
private Task<bool> ReadAsync_Read(Task<bool> task) { if (task.IsSuccess()) { if (task.Result) { return ProcessReaderEventAsync().ReturnTrueTaskWhenFinishAsync(); } else { _validator.EndValidation(); if (_coreReader.EOF) { _validationState = ValidatingReaderState.EOF; } return AsyncHelper.DoneTaskFalse; } } else { return _ReadAsync_Read(task); } }
//call nextTaskFun after task finish. Check exception. private Task SequenceRun(Task task, Func<Task> nextTaskFun) { if (task.IsSuccess()) { return TryReturnTask( nextTaskFun() ); } else { return _SequenceRun(task, nextTaskFun); } }
private Task AdvanceStateAsync_ContinueWhenFinish(Task task, State newState, Token token) { if (task.IsSuccess()) { currentState = newState; return AdvanceStateAsync(token); } else { return _AdvanceStateAsync_ContinueWhenFinish(task, newState, token); } }
//check if any exception before return the task private Task TryReturnTask(Task task) { if (task.IsSuccess()) { return AsyncHelper.DoneTask; } else { return _TryReturnTask(task); } }
//call taskFun and change state in sequence private Task AdvanceStateAsync_ReturnWhenFinish(Task task, State newState) { if (task.IsSuccess()) { currentState = newState; return AsyncHelper.DoneTask; } else { return _AdvanceStateAsync_ReturnWhenFinish(task, newState); } }