Why don't I see anything in the console when I run the program below?
I see both done-messages when I uncomment both lines (why not only "Foo Done!"
?)
class Program
{
static void Main(string[] args)
{
//var foo = new Foo();
var bar = new Bar();
}
private class Foo
{
public Foo()
{
DoWork();
}
private void DoWork()
{
Console.WriteLine("Foo Done!");
}
}
private class Bar
{
public Bar()
{
DoWorkAsync();
}
private async void DoWorkAsync()
{
await Task.Run(() => Console.WriteLine("Bar Done!"));
}
}
}