Skip to content

Instantly share code, notes, and snippets.

@ierhalim
Created January 1, 2021 11:59
Show Gist options
  • Select an option

  • Save ierhalim/76c16d86e4ece164f026543285df8ab0 to your computer and use it in GitHub Desktop.

Select an option

Save ierhalim/76c16d86e4ece164f026543285df8ab0 to your computer and use it in GitHub Desktop.
Y602 Paralel Programlama
using System;
using System.Threading.Tasks;
namespace ContinueWhenAllExample
{
class Program
{
static void Main(string[] args)
{
var task1 = Task.Run(() =>
{
Console.WriteLine("Task 1 running");
return "Task 1 result";
});
var task2 = Task.Run(() =>
{
Console.WriteLine("Task 2 running");
return "Task 2 result";
});
var task3 = Task.Factory.ContinueWhenAll(new Task<string>[] { task1, task2 }, (taskList) =>
{
foreach (var task in taskList)
{
Console.WriteLine(task.Result);
}
});
task3.Wait();
Console.ReadKey();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment