packages/Windows API Code Pack 1.1/source/Samples/Shell/StarBackupUsingLibraries/CS/BackupProcessPage.xaml.cs
/// <summary>
/// The method that does the real work. 
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
The method that does the real work.
The method that does the real work .
void bw_DoWork(object sender, DoWorkEventArgs e)
        {
            int current = 1;
            foreach (ListBoxItem lbi in listBox1.Items)
            {
                if (((BackgroundWorker)sender).CancellationPending)
                    e.Cancel = true;
                else
                {
                    Thread.Sleep(2000);
                    ((BackgroundWorker)sender).ReportProgress((current / listBox1.Items.Count) * 100, lbi);
                    current++;
                }
            }
        }
void bw_DoWork ( object sender , DoWorkEventArgs e ) { int current = 1 ; foreach ( ListBoxItem lbi in listBox1 . Items ) { if ( ( ( BackgroundWorker ) sender ) . CancellationPending ) e . Cancel = true ; else { Thread . Sleep ( 2000 ) ; ( ( BackgroundWorker ) sender ) . ReportProgress ( ( current / listBox1 . Items . Count ) * 100 , lbi ) ; current ++ ; } } }
The method that does the real work.
The method that does the real work .
// Our counter for the folder that we are currently backing up // Loop through all the items and back each folder up // Since the item is just a string path, we could create a ShellFolder (using ShellFolder.FromPath) // and then enumerate all the subitems in that folder. // If user has requested a cancel, set our event arg // Do a fake copy/backup of folder ... // Sleep two seconds // Once the copy has been done, report progress back to the Background Worker. // This could be used for a ProgressBar, or in our case, show "check" icon next // to each folder that was backed up. // Increment our counter for folders.
sender
object
None
e
DoWorkEventArgs
None