Alxandr / SpotiFire

A project to make a SpotifyClient in C#
http://nudoc.azurewebsites.net/SpotiFire
40 stars 19 forks source link

await sometimes deadlocks #68

Open NeoLegends opened 8 years ago

NeoLegends commented 8 years ago

I'm really not sure why, but in some / most cases, awaiting a SpotiFire-object causes a deadlock. The await never completes. We should check whether this is because the library never sets is_loaded to true, or because of threading issues.

At the moment I'm working around this problem by doing a manual wait. It's dead ugly though, especially since this is exactly what the await was introduced for.

while (!resource.IsLoaded) {
    await Task.Delay(50);
}

I'm using WPF btw, so the continuations will be run on the current Dispatcher.

EDIT: await only seems to fail on the PlaylistContainer, not on the resources that are loaded via IAsyncLoaded.