Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

warning about Task.Run()

$
0
0

Hi All,

I have a question about how to use Task.Run(). Code is like below:

public async Task GetResult()
{
Result result = new Result:

  result = await new Manipulator().GetResult();

  if (result.Valid)
  {
   ApiManager mgr = new ApiManager ();
       Task.Run( async () => await mgr.UploadResult ( result ));          // just send result to server, as it takes a bit time, so don't wait here.
  }

 return result;

}

Code is above, should I use Task.Run() there for the task which I don't need to wait for result?
And I get a warning for the Task.Run():
"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."

Do I need to worry about this warning or is there a better way to do it?

Thanks in advance.

Ting


Viewing all articles
Browse latest Browse all 77050

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>