Fix WaitToPosition logic
This commit is contained in:
parent
1ae767087f
commit
503379079b
@ -412,7 +412,6 @@ namespace AaxDecrypter
|
|||||||
|
|
||||||
var toRead = Math.Min(count, Length - Position);
|
var toRead = Math.Min(count, Length - Position);
|
||||||
WaitToPosition(Position + toRead);
|
WaitToPosition(Position + toRead);
|
||||||
|
|
||||||
return _readFile.Read(buffer, offset, count);
|
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>
|
/// <param name="requiredPosition">The minimum required flished data length in <see cref="SaveFilePath"/>.</param>
|
||||||
private void WaitToPosition(long requiredPosition)
|
private void WaitToPosition(long requiredPosition)
|
||||||
{
|
{
|
||||||
while (requiredPosition > WritePosition
|
while (WritePosition < requiredPosition
|
||||||
&& hasBegunDownloading
|
&& hasBegunDownloading
|
||||||
&& !IsCancelled
|
&& !IsCancelled
|
||||||
&& !downloadEnded.WaitOne(0)
|
&& !downloadEnded.WaitOne(0))
|
||||||
&& !downloadedPiece.WaitOne(100)) ;
|
{
|
||||||
|
downloadedPiece.WaitOne(100);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Close()
|
public override void Close()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user