-
-
Save dterracino/e2421cc4efe179fe5ce811af036d27b6 to your computer and use it in GitHub Desktop.
async console applicatiion main
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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