示例#1
0
        public void DoDownload()
        {
            double total   = 10000;
            double already = 0;
            Random rnd     = new Random();

            while (already < total)
            {
                System.Threading.Thread.Sleep(500);
                already += (rnd.NextDouble() / 4) * total;
                if (already > total)
                {
                    already = total;
                }

                if (Downing != null)
                {
                    DownloadEventArgs args = new DownloadEventArgs();
                    args.Percent = already / total;
                    Downing(this, args);
                }
            }
        }
示例#2
0
 static void ShowProgress(object sender, DownloadEventArgs e)
 {
     Console.WriteLine($"Downloading . . . {e.Percent:##.#%}");
 }