Is it possible not to wait for an asynchronous method call?

I have an application that will upload files. I do not want my application to stop while the file is loading, so I want to execute the task asynchronously. I have something like this:

class Program { static void Main(string[] args) { //less than 5 seconds PrepareUpload(); } private static async Task PrepareUpload() { //processing await Upload(); //processing } private static Task Upload() { var task = Task.Factory.StartNew(() => System.Threading.Thread.Sleep(5000)); return task; } } 

Exceptions are handled internally, so this is not a problem.

Is it possible to use async / away, how to shoot, and forget about it?

+7
source share
1 answer

In the console application you need to wait. Otherwise, your application will exit by completing all background threads and asynchronous operations that are in progress.

+9
source

All Articles