Guest User

Untitled

a guest
Mar 7th, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.90 KB | None | 0 0
  1. private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
  2.         {
  3.             richTextBox1.Invoke(new Action(delegate () { richTextBox1.Text += "Downloading file: "; }));
  4.  
  5.             Task task = new Task (() => {
  6.                 WebClient client = new WebClient();
  7.                 Console.WriteLine("Down");
  8.                 client.DownloadProgressChanged += new DownloadProgressChangedEventHandler(client_DownloadProgressChanged);
  9.                 client.DownloadFileCompleted += new AsyncCompletedEventHandler(client_DownloadFileCompleted);
  10.                 client.DownloadFileAsync(new Uri("http://distro.ibiblio.org/damnsmall/current/dsl-4.4.10-syslinux.iso"), @"E:\dls.iso");
  11.                 while(client.IsBusy);
  12.            });
  13.                  
  14.           task.RunSynchronously();
  15.           richTextBox1.Invoke(new Action(delegate () { richTextBox1.Text += "DONE "+Environment.NewLine; }));
Advertisement
Add Comment
Please, Sign In to add comment