Created
October 27, 2017 13:58
-
-
Save M-Yankov/945d7052b80870335f7e2165e65a13f7 to your computer and use it in GitHub Desktop.
How to execute something asynchronous
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var taskArray = new Task[tasksCount]; | |
for (int index = 0; index < taskArray.Length; index++) | |
{ | |
var productId = productIds[index]; | |
var task = Task.Run(() => UpdatePoductStatus(productId, Status.Available)); | |
taskArray[index] = task; | |
} | |
Task.WaitAll(taskArray); | |
// UpdatePoductStatus is a method declared somewhere in the code. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment