6

In Stephan Cleary's recent blog post about Async Console Apps on .NET CoreCLR he shows us that in CoreCLR (currently running on Visual Studio 2015, CTP6), the entry point "Main" can actually be marked as async Task, compile properly and actually run:

public class Program
{
    public async Task Main(string[] args)
    {
        Console.WriteLine("Hello World");
        await Task.Delay(TimeSpan.FromSeconds(1));
        Console.WriteLine("Still here!");
        Console.ReadLine();
    }
}

Gives the following output:

async Main entry point

This is strengthend by a blog post from the ASP.NET team called A Deep Dive into the ASP.NET 5 Runtime:

In addition to a static Program.Main entry point, the KRE supports instance-based entry points. You can even make the main entry point asynchronous and return a Task. By having the main entry point be an instance method, you can have services injected into your application by the runtime environment.

We know that up until now, An entry point cannot be marked with the 'async' modifier. So, how is that actually possible in the new CoreCLR runtime?

4

1 に答える 1