Task<StandardResponse<bool>> qcTask;
Task<StandardResponse<bool>> ccTask;
Task<StandardResponse<bool>> cfTask;
qcTask = service.ProcessQuestionsAndComments(inputData);
if (StatusId == (int)STATUS.COMPLETED)
{
ccTask = service.ProcessCompletedStatus(inputData);
cfTask = service.ProcessCompletedFile(inputData);
}
await Task.WhenAll(qcTask, ccTask, cfTask).ConfigureAwait(false);
problem here is, in the last line I cant use ccTask, cfTask as they are not assigned.
I tried with using some default task in else, but its state always stays in Created. something like this
else
{
ccTask = new Task<StandardResponse<bool>>(() => { return new StandardResponse<bool>() { Status = HttpStatusCode.OK }; });
cfTask = new Task<StandardResponse<bool>>(() => { return new StandardResponse<bool>() { Status = HttpStatusCode.OK }; });
}
anyway I can handle this task conditionaly.