diff --git a/src/ImageSharp/Formats/Png/PngEncoder.cs b/src/ImageSharp/Formats/Png/PngEncoder.cs index 61ea7c468..b0b4667de 100644 --- a/src/ImageSharp/Formats/Png/PngEncoder.cs +++ b/src/ImageSharp/Formats/Png/PngEncoder.cs @@ -72,13 +72,11 @@ namespace SixLabors.ImageSharp.Formats.Png /// The to encode from. /// The to encode the image data to. /// A representing the asynchronous operation. - public async Task EncodeAsync(Image image, Stream stream) + public Task EncodeAsync(Image image, Stream stream) where TPixel : unmanaged, IPixel { - using (var encoder = new PngEncoderCore(image.GetMemoryAllocator(), image.GetConfiguration(), new PngEncoderOptions(this))) - { - await encoder.EncodeAsync(image, stream).ConfigureAwait(false); - } + using var encoder = new PngEncoderCore(image.GetMemoryAllocator(), image.GetConfiguration(), new PngEncoderOptions(this)); + return encoder.EncodeAsync(image, stream); } } } diff --git a/src/ImageSharp/Image.cs b/src/ImageSharp/Image.cs index 7800a5c6f..605f5e0da 100644 --- a/src/ImageSharp/Image.cs +++ b/src/ImageSharp/Image.cs @@ -103,15 +103,15 @@ namespace SixLabors.ImageSharp /// /// The stream to save the image to. /// The encoder to save the image with. - /// Thrown if the stream or encoder is null. + /// Thrown if the stream or encoder is null. /// A representing the asynchronous operation. - public async Task SaveAsync(Stream stream, IImageEncoder encoder) + public Task SaveAsync(Stream stream, IImageEncoder encoder) { Guard.NotNull(stream, nameof(stream)); Guard.NotNull(encoder, nameof(encoder)); this.EnsureNotDisposed(); - await this.AcceptVisitorAsync(new EncodeVisitor(encoder, stream)).ConfigureAwait(false); + return this.AcceptVisitorAsync(new EncodeVisitor(encoder, stream)); } /// @@ -179,9 +179,8 @@ namespace SixLabors.ImageSharp public void Visit(Image image) where TPixel : unmanaged, IPixel => this.encoder.Encode(image, this.stream); - public async Task VisitAsync(Image image) - where TPixel : unmanaged, IPixel - => await this.encoder.EncodeAsync(image, this.stream).ConfigureAwait(false); + public Task VisitAsync(Image image) + where TPixel : unmanaged, IPixel => this.encoder.EncodeAsync(image, this.stream); } } }