Skip to content

Commit 3c82b03

Browse files
author
Jonas Dellinger
authored
Merge pull request #106 from petrroll/configureAwaitFix
Configure await fix + removed bunch of unnecessary async/await before return
2 parents 812a11d + 1ae1f23 commit 3c82b03

4 files changed

Lines changed: 131 additions & 132 deletions

File tree

SpotifyAPI/Local/Models/Track.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public async Task<Bitmap> GetAlbumArtAsync(AlbumArtSize size)
103103
string url = GetAlbumArtUrl(size);
104104
if (url == "")
105105
return null;
106-
var data = await wc.DownloadDataTaskAsync(url);
106+
var data = await wc.DownloadDataTaskAsync(url).ConfigureAwait(false);
107107
using (MemoryStream ms = new MemoryStream(data))
108108
{
109109
return (Bitmap)Image.FromStream(ms);
@@ -116,15 +116,15 @@ public async Task<Bitmap> GetAlbumArtAsync(AlbumArtSize size)
116116
/// </summary>
117117
/// <param name="size">AlbumArtSize (160,320,640)</param>
118118
/// <returns>A byte[], which is the albumart in binary data</returns>
119-
public async Task<byte[]> GetAlbumArtAsByteArrayAsync(AlbumArtSize size)
119+
public Task<byte[]> GetAlbumArtAsByteArrayAsync(AlbumArtSize size)
120120
{
121121
using (WebClient wc = new WebClient())
122122
{
123123
wc.Proxy = null;
124124
string url = GetAlbumArtUrl(size);
125125
if (url == "")
126126
return null;
127-
return await wc.DownloadDataTaskAsync(url);
127+
return wc.DownloadDataTaskAsync(url);
128128
}
129129
}
130130

SpotifyAPI/Local/RemoteHandler.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,23 +24,23 @@ internal Boolean Init()
2424

2525
internal async Task SendPauseRequest()
2626
{
27-
await QueryAsync("remote/pause.json?pause=true", true, true, -1);
27+
await QueryAsync("remote/pause.json?pause=true", true, true, -1).ConfigureAwait(false);
2828
}
2929

3030
internal async Task SendPlayRequest()
3131
{
32-
await QueryAsync("remote/pause.json?pause=false", true, true, -1);
32+
await QueryAsync("remote/pause.json?pause=false", true, true, -1).ConfigureAwait(false);
3333
}
3434

3535
internal async Task SendPlayRequest(string url, string context = "")
3636
{
3737
// TODO: instead of having an empty context, one way to fix the bug with the playback time beyond the length of a song would be to provide a 1-song context, and it would be fixed.
38-
await QueryAsync($"remote/play.json?uri={url}&context={context}", true, true, -1);
38+
await QueryAsync($"remote/play.json?uri={url}&context={context}", true, true, -1).ConfigureAwait(false);
3939
}
4040

4141
internal async Task SendQueueRequest(string url)
4242
{
43-
await QueryAsync("remote/play.json?uri=" + url + "?action=queue", true, true, -1);
43+
await QueryAsync("remote/play.json?uri=" + url + "?action=queue", true, true, -1).ConfigureAwait(false);
4444
}
4545

4646
internal StatusResponse GetNewStatus()
@@ -151,7 +151,7 @@ internal async Task<string> QueryAsync(string request, bool oauth, bool cfid, in
151151
using (var wc = new ExtendedWebClient())
152152
{
153153
if (SpotifyLocalAPI.IsSpotifyRunning())
154-
response = "[ " + await wc.DownloadStringTaskAsync(new Uri(address)) + " ]";
154+
response = "[ " + await wc.DownloadStringTaskAsync(new Uri(address)).ConfigureAwait(false) + " ]";
155155
}
156156
}
157157
catch

0 commit comments

Comments
 (0)