Skip to content

Commit

Permalink
rafactor program.cs of sample project to support MacOS
Browse files Browse the repository at this point in the history
  • Loading branch information
bezzad committed Aug 27, 2024
1 parent 4276d41 commit b87035e
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions src/Samples/Downloader.Sample/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ private static async Task DownloadAll(IEnumerable<DownloadItem> downloadList, Ca

// begin download from url
await DownloadFile(downloadItem).ConfigureAwait(false);

await Task.Yield();
}
}

Expand Down Expand Up @@ -181,14 +183,17 @@ private static async Task<bool> ValidateDataAsync(string filename, long size)
return true;
}

private static void WriteKeyboardGuidLines()
private static async Task WriteKeyboardGuidLines()
{
Console.Clear();
Console.WriteLine("Press Esc to Stop current file download");
Console.WriteLine("Press P to Pause and R to Resume downloading");
Console.WriteLine("Press Up Arrow to Increase download speed 2X");
Console.WriteLine("Press Down Arrow to Decrease download speed 2X");
Console.WriteLine();
Console.Beep();
Console.CursorVisible = false;
await Console.Out.WriteLineAsync("Press Esc to Stop current file download");
await Console.Out.WriteLineAsync("Press P to Pause and R to Resume downloading");
await Console.Out.WriteLineAsync("Press Up Arrow to Increase download speed 2X");
await Console.Out.WriteLineAsync("Press Down Arrow to Decrease download speed 2X \n");
await Console.Out.FlushAsync();
await Task.Yield();
}
private static DownloadService CreateDownloadService(DownloadConfiguration config)
{
Expand All @@ -215,9 +220,9 @@ private static DownloadService CreateDownloadService(DownloadConfiguration confi
return downloadService;
}

private static void OnDownloadStarted(object sender, DownloadStartedEventArgs e)
private static async void OnDownloadStarted(object sender, DownloadStartedEventArgs e)
{
WriteKeyboardGuidLines();
await WriteKeyboardGuidLines();
ConsoleProgress = new ProgressBar(10000, $"Downloading {Path.GetFileName(e.FileName)} ", ProcessBarOption);
}

Expand Down

0 comments on commit b87035e

Please sign in to comment.