diff --git a/src/ICSharpCode.SharpZipLib/Zip/ZipFile.cs b/src/ICSharpCode.SharpZipLib/Zip/ZipFile.cs
index 704911b3f..c0bf53060 100644
--- a/src/ICSharpCode.SharpZipLib/Zip/ZipFile.cs
+++ b/src/ICSharpCode.SharpZipLib/Zip/ZipFile.cs
@@ -9,6 +9,8 @@
using System.IO;
using System.Security.Cryptography;
using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
namespace ICSharpCode.SharpZipLib.Zip
{
@@ -4223,6 +4225,35 @@ public override int Read(byte[] buffer, int offset, int count)
}
}
+ ///
+ public override async Task ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
+ {
+ // lock (baseStream_)
+ {
+ if (count > end_ - readPos_)
+ {
+ count = (int)(end_ - readPos_);
+ if (count == 0)
+ {
+ return 0;
+ }
+ }
+ // Protect against Stream implementations that throw away their buffer on every Seek
+ // (for example, Mono FileStream)
+ if (baseStream_.Position != readPos_)
+ {
+ baseStream_.Seek(readPos_, SeekOrigin.Begin);
+ }
+
+ int readCount = await baseStream_.ReadAsync(buffer, offset, count, cancellationToken);
+ if (readCount > 0)
+ {
+ readPos_ += readCount;
+ }
+ return readCount;
+ }
+ }
+
///
/// Writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written.
///