Fix WaitToPosition logic

This commit is contained in:
Michael Bucari-Tovo 2022-06-21 00:23:02 -06:00
parent 1ae767087f
commit 503379079b

View File

@ -412,7 +412,6 @@ namespace AaxDecrypter
var toRead = Math.Min(count, Length - Position);
WaitToPosition(Position + toRead);
return _readFile.Read(buffer, offset, count);
}
@ -435,11 +434,13 @@ namespace AaxDecrypter
/// <param name="requiredPosition">The minimum required flished data length in <see cref="SaveFilePath"/>.</param>
private void WaitToPosition(long requiredPosition)
{
while (requiredPosition > WritePosition
while (WritePosition < requiredPosition
&& hasBegunDownloading
&& !IsCancelled
&& !downloadEnded.WaitOne(0)
&& !downloadedPiece.WaitOne(100)) ;
&& !downloadEnded.WaitOne(0))
{
downloadedPiece.WaitOne(100);
}
}
public override void Close()