so I have an async method wrapped in Task.Run like so:
//SynchronisationContext = UI Thread
await Task.Run(async =>
{
for (int i = 0; i < 100; i++)
{
var res = ComplicatedCalulation(); //Takes about 1 second
await ThirdPartyLib.WriteToDatabase(res);
}
});
Does the await on the above code await the async lambda code or does it just await the Task
being started (i.e. returning straight away)
I know with Task.Factory.StartNew
the correct use is
await Task.Factory.StartNew<Task>(async => await MyAsyncMethod()).Result
Is this also true for Task.Run?