Skip to content

Commit

Permalink
updated Helper.cs of Sample project to support macOS terminal
Browse files Browse the repository at this point in the history
  • Loading branch information
bezzad committed Sep 2, 2024
1 parent 6cb65e9 commit 307f676
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/Samples/Downloader.Sample/Helper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public static string CalcMemoryMensurableUnit(this double bytes)
return result;
}

public static void UpdateTitleInfo(this DownloadProgressChangedEventArgs e, bool isPaused)
public static string UpdateTitleInfo(this DownloadProgressChangedEventArgs e, bool isPaused)
{
int estimateTime = (int)Math.Ceiling((e.TotalBytesToReceive - e.ReceivedBytesSize) / e.AverageBytesPerSecondSpeed);
string timeLeftUnit = "seconds";
Expand All @@ -49,12 +49,12 @@ public static void UpdateTitleInfo(this DownloadProgressChangedEventArgs e, bool
string progressPercentage = $"{e.ProgressPercentage:F3}".Replace("/", ".");
string usedMemory = GC.GetTotalMemory(false).CalcMemoryMensurableUnit();

Console.Title = $"{estimateTime} {timeLeftUnit} left - " +
$"{speed}/s (avg: {avgSpeed}/s) - " +
$"{progressPercentage}% - " +
$"[{bytesReceived} of {totalBytesToReceive}] " +
$"Active Chunks: {e.ActiveChunks} - " +
$"[{usedMemory} memory] " +
(isPaused ? " - Paused" : "");
return $"{estimateTime} {timeLeftUnit} left - " +
$"{speed}/s (avg: {avgSpeed}/s) - " +
$"{progressPercentage}% - " +
$"[{bytesReceived} of {totalBytesToReceive}] " +
$"Active Chunks: {e.ActiveChunks} - " +
$"[{usedMemory} memory] " +
(isPaused ? " - Paused" : "");
}
}

0 comments on commit 307f676

Please sign in to comment.