From de326b2e7154c4cfb113e4888b204aa4d6f7d8e2 Mon Sep 17 00:00:00 2001 From: Jenny Lian Date: Sat, 17 Oct 2020 14:14:11 -0700 Subject: [PATCH] multi-task hello world --- HelloWorldAsyncMultiTask.cs | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 HelloWorldAsyncMultiTask.cs diff --git a/HelloWorldAsyncMultiTask.cs b/HelloWorldAsyncMultiTask.cs new file mode 100644 index 0000000..8eeae99 --- /dev/null +++ b/HelloWorldAsyncMultiTask.cs @@ -0,0 +1,29 @@ +using System; + +namespace HelloWorldApp { + + class Program + { + + public static async Task Main(string[] args) + { + var helloTask = helloAsync(); + var worldTask = WorldAsync(); + + Task.WaitAll(helloTask, worldTask); + Console.WriteLine(helloTask.Result); + Console.WriteLine(worldTask.Result); + + } + + private static async Task helloAsync() + { + return "Hello"; + } + + private static async Task WorldAsync() + { + return "World"; + } + } +}