I am getting an error when looping array from async method as Parallel. When debuging, I can see count of the resultsArray is 11. But after stepping over a few times, it showed me "Source array was not long enough" Can I please get what the issue of my code?
public async Task<IActionResult> Generate(int id)
{
List<Product> products = new List<Product>();
Result[] resultArray = await Manager.GetResultArray();
Parallel.ForEach(resultArray , result=> //Error here
{
SomeMethod(result)); // SomeMethod cast result to Produc class and add to products list
});
...
}