I have:
async Task doWork() { Console.WriteLine("do some async work in this method"); }
Task task = new Task(doWork); //line X
task.Start();
task.Wait();
Line X gives a compilation error:
CS0407 'Task Form1.doWork()' has the wrong return type
How do I instantiate a new Task doWork
?
I am able to use the following but it gives me a different set of problems.
Task task = doWork();
task.Wait();
I want to avoid this second method. How do I instantiate a new Task
of type async Task
at line X?