mirror of
https://git.naxdy.org/Mirror/Ryujinx.git
synced 2024-12-27 11:03:04 +00:00
OK nevermind found a way to fix IDE0057
This commit is contained in:
parent
c0c873243f
commit
a29f167593
2 changed files with 11 additions and 7 deletions
|
@ -105,20 +105,24 @@ namespace Ryujinx.Modules
|
||||||
using var memoryStream = new MemoryStream();
|
using var memoryStream = new MemoryStream();
|
||||||
int bytesRead;
|
int bytesRead;
|
||||||
long totalRead = 0;
|
long totalRead = 0;
|
||||||
|
int lastReportedProgress = -1;
|
||||||
|
|
||||||
while ((bytesRead = await stream.ReadAsync(buffer, CancellationToken.None)) > 0)
|
while ((bytesRead = await stream.ReadAsync(buffer, CancellationToken.None)) > 0)
|
||||||
{
|
{
|
||||||
#pragma warning disable IDE0057 // Disable the warning for unnecessary slicing
|
memoryStream.Write(buffer.Span[..bytesRead]);
|
||||||
memoryStream.Write(buffer.Slice(0, bytesRead).ToArray(), 0, bytesRead);
|
|
||||||
#pragma warning restore IDE0057
|
|
||||||
totalRead += bytesRead;
|
totalRead += bytesRead;
|
||||||
int progress = (int)((totalRead * 100) / (end - start + 1));
|
int progress = (int)((totalRead * 100) / (end - start + 1));
|
||||||
progressPercentage[index] = progress;
|
progressPercentage[index] = progress;
|
||||||
|
|
||||||
Dispatcher.UIThread.Post(() =>
|
// Throttle UI updates to only fire when there is a change in progress percentage
|
||||||
|
if (progress != lastReportedProgress)
|
||||||
{
|
{
|
||||||
taskDialog.SetProgressBarState(progressPercentage.Sum() / ConnectionCount, TaskDialogProgressState.Normal);
|
lastReportedProgress = progress;
|
||||||
});
|
Dispatcher.UIThread.Post(() =>
|
||||||
|
{
|
||||||
|
taskDialog.SetProgressBarState(progressPercentage.Sum() / ConnectionCount, TaskDialogProgressState.Normal);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return memoryStream.ToArray();
|
return memoryStream.ToArray();
|
||||||
|
|
|
@ -42,7 +42,7 @@ namespace Ryujinx.Modules
|
||||||
|
|
||||||
while ((readSize = await remoteFileStream.ReadAsync(buffer, CancellationToken.None)) > 0)
|
while ((readSize = await remoteFileStream.ReadAsync(buffer, CancellationToken.None)) > 0)
|
||||||
{
|
{
|
||||||
updateFileStream.Write(buffer.Span.Slice(0, readSize));
|
updateFileStream.Write(buffer.Span[..readSize]);
|
||||||
byteWritten += readSize;
|
byteWritten += readSize;
|
||||||
|
|
||||||
Dispatcher.UIThread.Post(() =>
|
Dispatcher.UIThread.Post(() =>
|
||||||
|
|
Loading…
Reference in a new issue