Found the issue: As soon as I iterate through the models list via AsParallel().ForAll , it might happen (depends on the CPU workload) that the task to create (async) has not been yet created but is being accessed by the WhenAll method (async too), and retrievestherefore throws the exception mentioned above. This happens sometimes, as I said based on, according to the CPU workload. To: In order to easily reproduce the issue easily, II've created a unit test thatwhich calls to the problematic method up to 50 times, and usually fails beforewithin the first 10 runs. In order to To solve the issue, I I've replaced the useless (because in this scenario does not bring anything relevant) function AsParallel().ForAll by ForEachand and the issue does not happen anymore because the taskstasks are always createdcreated following a sequence (not executed though, they are executed asynchronously), no matter the CPU workload. Code will be as follows, to solve the issue:
List<Model> ftpModels = _service.CreateFtpModel(rowsFromDB); List<Task> asyncTasks = new List<Task>(); ftpModels.ForEach(p => { asyncTasks.Add(DoStepsAsync(p)); }); // Wait for all the tasks to finish. await Task.WhenAll(asyncTasks.Where(p => p != null)); I hope it helps in the future to other people.