Use recommended async dispose pattern

Funny enough, non-breaking API changes since all of those classes are sealed.
This commit is contained in:
JustArchi
2022-06-19 18:24:52 +02:00
parent 82750352e2
commit 772607b680
7 changed files with 81 additions and 41 deletions

View File

@@ -27,7 +27,7 @@ using JetBrains.Annotations;
namespace ArchiSteamFarm.Web.Responses;
public sealed class StreamResponse : BasicResponse, IAsyncDisposable {
public sealed class StreamResponse : BasicResponse, IAsyncDisposable, IDisposable {
[PublicAPI]
public Stream? Content { get; }
@@ -43,6 +43,11 @@ public sealed class StreamResponse : BasicResponse, IAsyncDisposable {
Length = httpResponseMessage.Content.Headers.ContentLength.GetValueOrDefault();
}
public void Dispose() {
Content?.Dispose();
ResponseMessage.Dispose();
}
public async ValueTask DisposeAsync() {
if (Content != null) {
await Content.DisposeAsync().ConfigureAwait(false);