Skip to content

Commit 80f58df

Browse files
committed
Fixed rest of awaits.
1 parent a67305c commit 80f58df

3 files changed

Lines changed: 16 additions & 14 deletions

File tree

SpotifyAPI/Local/Models/Track.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,9 @@ 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 =
107+
108+
wc.DownloadDataTaskAsync(url);
107109
using (MemoryStream ms = new MemoryStream(data))
108110
{
109111
return (Bitmap)Image.FromStream(ms);
@@ -116,15 +118,15 @@ public async Task<Bitmap> GetAlbumArtAsync(AlbumArtSize size)
116118
/// </summary>
117119
/// <param name="size">AlbumArtSize (160,320,640)</param>
118120
/// <returns>A byte[], which is the albumart in binary data</returns>
119-
public async Task<byte[]> GetAlbumArtAsByteArrayAsync(AlbumArtSize size)
121+
public Task<byte[]> GetAlbumArtAsByteArrayAsync(AlbumArtSize size)
120122
{
121123
using (WebClient wc = new WebClient())
122124
{
123125
wc.Proxy = null;
124126
string url = GetAlbumArtUrl(size);
125127
if (url == "")
126128
return null;
127-
return await wc.DownloadDataTaskAsync(url);
129+
return wc.DownloadDataTaskAsync(url);
128130
}
129131
}
130132

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 void 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 void 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 void 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 void 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

SpotifyAPI/Web/SpotifyWebClient.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public async Task<Tuple<ResponseInfo, string>> DownloadAsync(string url)
5757
Tuple<ResponseInfo, string> response;
5858
try
5959
{
60-
Tuple<ResponseInfo, byte[]> raw = await DownloadRawAsync(url);
60+
Tuple<ResponseInfo, byte[]> raw = await DownloadRawAsync(url).ConfigureAwait(false);
6161
response = new Tuple<ResponseInfo, string>(raw.Item1, raw.Item2.Length > 0 ? _encoding.GetString(raw.Item2) : "{}");
6262
}
6363
catch (WebException e)
@@ -91,7 +91,7 @@ public async Task<Tuple<ResponseInfo, byte[]>> DownloadRawAsync(string url)
9191
webClient.Encoding = _encoding;
9292
webClient.Headers = _webClient.Headers;
9393

94-
byte[] data = await _webClient.DownloadDataTaskAsync(url);
94+
byte[] data = await _webClient.DownloadDataTaskAsync(url).ConfigureAwait(false);
9595
ResponseInfo info = new ResponseInfo()
9696
{
9797
Headers = webClient.ResponseHeaders
@@ -108,7 +108,7 @@ public Tuple<ResponseInfo, T> DownloadJson<T>(string url)
108108

109109
public async Task<Tuple<ResponseInfo, T>> DownloadJsonAsync<T>(string url)
110110
{
111-
Tuple<ResponseInfo, string> response = await DownloadAsync(url);
111+
Tuple<ResponseInfo, string> response = await DownloadAsync(url).ConfigureAwait(false);
112112
return new Tuple<ResponseInfo, T>(response.Item1, JsonConvert.DeserializeObject<T>(response.Item2, JsonSettings));
113113
}
114114

@@ -138,7 +138,7 @@ public async Task<Tuple<ResponseInfo, string>> UploadAsync(string url, string bo
138138
Tuple<ResponseInfo, string> response;
139139
try
140140
{
141-
Tuple<ResponseInfo, byte[]> data = await UploadRawAsync(url, body, method);
141+
Tuple<ResponseInfo, byte[]> data = await UploadRawAsync(url, body, method).ConfigureAwait(false);
142142
response = new Tuple<ResponseInfo, string>(data.Item1, data.Item2.Length > 0 ? _encoding.GetString(data.Item2) : "{}");
143143
}
144144
catch (WebException e)
@@ -171,7 +171,7 @@ public async Task<Tuple<ResponseInfo, byte[]>> UploadRawAsync(string url, string
171171
webClient.Proxy = null;
172172
webClient.Encoding = _encoding;
173173
webClient.Headers = _webClient.Headers;
174-
byte[] data = await _webClient.UploadDataTaskAsync(url, method, _encoding.GetBytes(body));
174+
byte[] data = await _webClient.UploadDataTaskAsync(url, method, _encoding.GetBytes(body)).ConfigureAwait(false);
175175
ResponseInfo info = new ResponseInfo
176176
{
177177
Headers = _webClient.ResponseHeaders
@@ -188,7 +188,7 @@ public Tuple<ResponseInfo, T> UploadJson<T>(string url, string body, string meth
188188

189189
public async Task<Tuple<ResponseInfo, T>> UploadJsonAsync<T>(string url, string body, string method)
190190
{
191-
Tuple<ResponseInfo, string> response = await UploadAsync(url, body, method);
191+
Tuple<ResponseInfo, string> response = await UploadAsync(url, body, method).ConfigureAwait(false);
192192
return new Tuple<ResponseInfo, T>(response.Item1, JsonConvert.DeserializeObject<T>(response.Item2, JsonSettings));
193193
}
194194

0 commit comments

Comments
 (0)