Skip to content

Instantly share code, notes, and snippets.

@datvm
Last active August 21, 2018 04:29
Show Gist options
  • Save datvm/8f51d308033b73725b686813fc16277b to your computer and use it in GitHub Desktop.
Save datvm/8f51d308033b73725b686813fc16277b to your computer and use it in GitHub Desktop.
Using async Task for entry Main method in C# (Enable C# 7.1 in Visual Studio Build)

The C# async/await syntax is very useful. However, even as of current latest major C# version 7.0, your program entry point has to use Wait() or similar methods if you need an async method.

This is solved in C# 7.1 (and with many other useful features). However, by default, Visual Studio 2017 uses latest MAJOR version (x.0). You need to change it into specific version, or latest MINOR version in order for the new features to be built successfully. And here's how:

Screenshot

  • Navigate menu Project Properties...

  • Build tab → Advanced...

  • In Language version option, choose C# latest minor version, or simply choose a version of your choice (as of the writing time, the latest is 7.3)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment