I have an async method M1Async
. I need to call it in the constructor of a class. At first, I just call the async method and let it run
M1Async();
It runs and did the work as I expected - it's fine it runs in the background and populates the Winforms controls. However, Visual Studio shows a green line under the call and suggest me to insert an await in front of the function.
Warning CS4014 Because this call is not awaited, execution of the current method continues before the call is completed. Consider applying the 'await' operator to the result of the call.
So I changed the invoking the async method without await to
Task.Run(M1Async);
Now the warning is gone.
Are they actually the same? Since the latter one doesn't have the warning, is it the better way to call it?