Skip to content

Instantly share code, notes, and snippets.

@dkudelko
Created October 6, 2015 10:56
Show Gist options
  • Save dkudelko/47956c00baa363fe06de to your computer and use it in GitHub Desktop.
Save dkudelko/47956c00baa363fe06de to your computer and use it in GitHub Desktop.
async console applicatiion main
class Program
{
static void Main(string[] args)
{
CancellationTokenSource cts = new CancellationTokenSource();
Console.CancelKeyPress += (s, e) =>
{
e.Cancel = true;
cts.Cancel();
};
MainAsync(args, cts.Token).Wait();
}
static async Task MainAsync(string[] args, CancellationToken token)
{
//todo paste your asnc code
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment