diff --git a/src/CDNClient.cs b/src/CDNClient.cs index 2c8450f..4e5ad69 100644 --- a/src/CDNClient.cs +++ b/src/CDNClient.cs @@ -357,7 +357,7 @@ public DepotManifest GetManifest(uint appId, ItemIdentifier item, ulong manifest try { var request = new HttpRequestMessage(HttpMethod.Get, new Uri($"https://{server}/depot/{item.DepotId}/manifest/{manifestId}/5/{requestCode}")) { Version = HttpVersion.Version20 }; - using var response = s_client.SendAsync(request, HttpCompletionOption.ResponseHeadersRead, cancellationToken).Result.EnsureSuccessStatusCode(); + using var response = s_client.SendAsync(request, HttpCompletionOption.ResponseHeadersRead, cancellationToken).GetAwaiter().GetResult().EnsureSuccessStatusCode(); uint? crc = uint.TryParse(response.Headers.TryGetValues("x-content-crc", out var headerValue) ? headerValue.FirstOrDefault() : null, out uint value) ? value : null; using var content = response.Content; int size = (int)(content.Headers.ContentLength ?? throw new NullReferenceException("Content-Length is missing")); @@ -420,7 +420,7 @@ public DepotPatch GetPatch(uint appId, ItemIdentifier item, DepotManifest source try { var request = new HttpRequestMessage(HttpMethod.Get, new Uri($"https://{server}/depot/{item.DepotId}/patch/{sourceManifest.Id}/{targetManifest.Id}")) { Version = HttpVersion.Version20 }; - using var response = s_client.SendAsync(request, HttpCompletionOption.ResponseHeadersRead, cancellationToken).Result.EnsureSuccessStatusCode(); + using var response = s_client.SendAsync(request, HttpCompletionOption.ResponseHeadersRead, cancellationToken).GetAwaiter().GetResult().EnsureSuccessStatusCode(); uint? crc = uint.TryParse(response.Headers.TryGetValues("x-content-crc", out var headerValue) ? headerValue.FirstOrDefault() : null, out uint value) ? value : null; using var content = response.Content; int size = (int)(content.Headers.ContentLength ?? throw new NullReferenceException("Content-Length is missing")); diff --git a/src/CM/CMClient.cs b/src/CM/CMClient.cs index 0467aaa..518b983 100644 --- a/src/CM/CMClient.cs +++ b/src/CM/CMClient.cs @@ -472,7 +472,7 @@ public FrozenDictionary GetDepotManifestIds(uint appId) try { var httpRequest = new HttpRequestMessage(HttpMethod.Get, new Uri($"{appId}/sha/{Convert.ToHexString(appInfo.Sha.Span)}.txt.gz")) { Version = HttpVersion.Version20 }; - using var httpResponse = s_clientConfigClient.SendAsync(httpRequest, HttpCompletionOption.ResponseContentRead, CancellationToken.None).Result.EnsureSuccessStatusCode(); + using var httpResponse = s_clientConfigClient.SendAsync(httpRequest, HttpCompletionOption.ResponseContentRead, CancellationToken.None).GetAwaiter().GetResult().EnsureSuccessStatusCode(); using var content = httpResponse.Content; using var reader = new StreamReader(new GZipStream(content.ReadAsStream(), CompressionMode.Decompress)); entries = new VDFEntry(reader)["depots"]?.Children; @@ -564,7 +564,7 @@ internal static void RefreshServerList() { string[]? serverList; using (var httpClient = new HttpClient() { DefaultRequestVersion = HttpVersion.Version20 }) - try { serverList = httpClient.GetFromJsonAsync($"https://api.steampowered.com/ISteamDirectory/GetCMList/v1?cellid={CellId}", JsonContext.Default.CMListResponse).Result?.Response?.ServerlistWebsockets; } + try { serverList = httpClient.GetFromJsonAsync($"https://api.steampowered.com/ISteamDirectory/GetCMList/v1?cellid={CellId}", JsonContext.Default.CMListResponse).GetAwaiter().GetResult()?.Response?.ServerlistWebsockets; } catch { serverList = null; } if (serverList is null) return; diff --git a/src/CM/WebSocketConnection.cs b/src/CM/WebSocketConnection.cs index c945055..eb23477 100644 --- a/src/CM/WebSocketConnection.cs +++ b/src/CM/WebSocketConnection.cs @@ -65,7 +65,7 @@ private void ConnectionLoop() _socket.CloseAsync(WebSocketCloseStatus.EndpointUnavailable, null, default).Wait(5000); break; } - var result = receiveTask.Result; + var result = receiveTask.GetAwaiter().GetResult(); if (result.MessageType is WebSocketMessageType.Close) { if (_socket.State is not WebSocketState.Closed or WebSocketState.Aborted) @@ -321,7 +321,7 @@ public void Disconnect() }; lock (_callbacks) _callbacks.Add(callback); - var result = Send(message) && callback.CompletionSource.Task.Wait(5000) ? (Message?)callback.CompletionSource.Task.Result : null; + var result = Send(message) && callback.CompletionSource.Task.Wait(5000) ? (Message?)callback.CompletionSource.Task.GetAwaiter().GetResult() : null; lock (_callbacks) _callbacks.Remove(callback); return result;