@@ -44,7 +44,8 @@ public Task<Image<TPixel>> DecodeAsync<TPixel>(Configuration configuration, Stre
4444
4545 /// <inheritdoc />
4646 public async Task < Image > DecodeAsync ( Configuration configuration , Stream stream , CancellationToken cancellationToken )
47- => await this . DecodeAsync < Rgba32 > ( configuration , stream , cancellationToken ) . ConfigureAwait ( false ) ;
47+ => await this . DecodeAsync < Rgba32 > ( configuration , stream , cancellationToken )
48+ . ConfigureAwait ( false ) ;
4849
4950 /// <inheritdoc/>
5051 public IImageInfo Identify ( Configuration configuration , Stream stream )
@@ -56,12 +57,18 @@ public IImageInfo Identify(Configuration configuration, Stream stream)
5657 }
5758
5859 /// <inheritdoc/>
59- public Task < IImageInfo > IdentifyAsync ( Configuration configuration , Stream stream , CancellationToken cancellationToken )
60+ public async Task < IImageInfo > IdentifyAsync ( Configuration configuration , Stream stream , CancellationToken cancellationToken )
6061 {
6162 Guard . NotNull ( stream , nameof ( stream ) ) ;
6263
63- using var decoder = new JpegDecoderCore ( configuration , this ) ;
64- return decoder . IdentifyAsync ( configuration , stream , cancellationToken ) ;
64+ // The introduction of a local variable that refers to an object the implements
65+ // IDisposable means you must use async/await, where the compiler generates the
66+ // state machine and a continuation.
67+ using ( var decoder = new JpegDecoderCore ( configuration , this ) )
68+ {
69+ return await decoder . IdentifyAsync ( configuration , stream , cancellationToken )
70+ . ConfigureAwait ( false ) ;
71+ }
6572 }
6673 }
6774}
0 commit comments