countdownevent
class Program
{
static void Main(string[] args)
{
CountdownEvent countObject = new CountdownEvent(10);
int[] result = new int[10];
for (int i = 0; i < 10; ++i)
{
int j = i;
Task.Factory.StartNew(() =>
{
Thread.Sleep(TimeSpan.FromSeconds(3));
result[j] = j * 10;
countObject.Signal();
});
}
countObject.Wait();
foreach (var r in result)
{
Console.WriteLine(r);
}
Console.ReadLine();
/* Result
* 0
* 10
* 20
* 30
* 40
* 50
* 60
* 70
* 80
* 90 */
}
}
Also in C#:
- asp.net core task iactionresult
- convert number of days into months c#
- unity position ui element
- convert string to datetime c#
- get setter c# model
- if get key down unity
- c# string array
- unity get number of child objects
- c# switct case
- c# how to open file explorer
- mysql C# select pk and all columns datareader
- how to clear console through script unity
- unity set position
- codecademy
- how to check if an integer is in array c#
- uinput dialog uwp c#
- change text color wpf
- asp.net get query string parameter
- c# get all inherited classes of a class
- eager loading vs lazy loading c#
- textblock line break
- c# md5 string
- gfortran: declare an array
- c# tostring mmm dd yyyy