Created
January 1, 2021 11:59
-
-
Save ierhalim/76c16d86e4ece164f026543285df8ab0 to your computer and use it in GitHub Desktop.
Y602 Paralel Programlama
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
| 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