Skip to content

Commit

Permalink
Fix possible freeze when downloading avatars
Browse files Browse the repository at this point in the history
  • Loading branch information
lanfeust69 committed Dec 8, 2018
1 parent fca7cf2 commit 7ebe98c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion GitUI/Avatars/AvatarDownloader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,11 @@ async Task<Image> Download()
{
webClient.Proxy.Credentials = CredentialCache.DefaultCredentials;

using (var imageStream = await webClient.OpenReadTaskAsync(imageUrl))
// actually, due to a .Net FX bug, WebClient.OpenReadTaskAsync *can* block before returning a Task
// let's make sure this doesn't happen on the current thread (likely the UI thread)
var readTask = Task.Run(() => webClient.OpenReadTaskAsync(imageUrl));

using (var imageStream = await readTask)
{
return Image.FromStream(imageStream);
}
Expand Down

0 comments on commit 7ebe98c

Please sign in to comment.