I would like each record in ForEach run Async. I don't have to wait for each result, so I can just iterate through the list and commission the record executed in the next Thread. But in the end, I need to return this list with all executed methods. Does anyone know how I could refactor this example code?
Example:
List<SomeObject> CalculateMissingVar(List<SomeObject> records) { foreach (var record in records) { //I woudl like run this method async without wating for each result record.PlaceForLongMathEquation = Calculate(5); } return records; } //This method shodul be Async int Calculate(int number) { return number * number; }