private async static Task AsyncMain()
{
var asyncShow = new AsyncShowcase();
/*
* A task can be started and not immediatley awaited.
*/
var t = Task.Run(() =>
{
Thread.Sleep(1000);
asyncShow.addValuesInRange(0, 10).Wait();
});
await asyncShow.addValue(10); // add 10 and wait
Console.WriteLine(await asyncShow.getValueAsync()); // can wait within function call and function will receive argument
await t;
if (await asyncShow.getValueAsync() == 55) // I can use await within a conditional
{
Console.WriteLine("Success!");
}
}