Can anyone explain to me the difference between these 2 async methods?
Method A
public async Task<List<Thumbnail>> GetAllThumbnailsAsync()
{
return await Task.Factory.StartNew(() =>
{
var imageUris = GetAllDirectoriesWithImageAsync(CommandBaseUri).Result;
return imageUris.Select(GetThumbnail).OrderByDescending(t => t.ImageDateTime).ToList();
});
}
Method B
public async Task<List<Thumbnail>> GetAllThumbnailsAsync()
{
var imageUris = await GetAllDirectoriesWithImageAsync(CommandBaseUri);
return imageUris.Select(GetThumbnail).OrderByDescending(t => t.ImageDateTime).ToList();
}
To my understanding both methods should return to the caller and does not block the UI thread, but in this case only Method A works as expected while Method B blocks my UI.
I believe there must be some fundamental concept that I may have misunderstood in the usage of async/await.
Can anyone enlighten me?