Monday, July 29, 2013

Crash when calling Task.Result from UI-Thread

in your first sample you call this from the ui thread:



private async Task<bool> DoSomething()
{
await Task.Delay(1000);
return true;
}

await will now try to invoke back in the UI thread but because the .Result its already blocked, so it will never get back


in your second sample all the awaits are already called from other threads and await will then not try to put it in the UI thread and that means it will keep working




Microsoft Certified Solutions Developer - Windows Store Apps Using C#


No comments:

Post a Comment