using System;
using System.Threading;
using System.Threading.Tasks;
namespace application
{
public class Files
{
public static Task<string> runTask()
{
return Task.Run(() =>
{
Thread.Sleep(2000);
return "Hello World!";
});
}
public static async void Hello()
{
string result = await runTask();
Console.WriteLine(result);
Console.WriteLine("Execution Ended!");
}
public static void Main(string[] args)
{
Hello();
Console.WriteLine("The Async Code Is Running Above!");
}
};
};
The above C# code just prints "The Async Code Is Running Above!" and nothing happens after that.
How can I make this print things in following order (And where I'm going wrong):
"The Async Code Is Running Above!" "Hello World!" "Execution Ended!"
Thankyou!