Exemplo n.º 1
0
        private void btnTestProgress_Click(object sender, EventArgs e)
        {
            //reset the progress bars to prevent them causing out of bounds errors
            resetProgressIndicators();

            //determine which button checked
            if (rdoSpinner.Checked)
            {
                dpt = new delegateProgressType(increaseSpinner);
            }
            else if (rdoProgressBar.Checked)
            {
                dpt = new delegateProgressType(increaseProgBar);
            }
            else if (rdoTrackbar.Checked)
            {
                dpt = new delegateProgressType(increaseTrackBar);
            }

            //pass slow method the delegate we just defined
            slowMethod(dpt);
        }
Exemplo n.º 2
0
 //Artificially slow down progress
 private void slowMethod(delegateProgressType delegateProgressType)
 {
     //Sleep 10 times to simulate progress
     for (int i = 0; i < 10; i++)
     {
         //Sleep 1s
         Thread.Sleep(1000);
         //Run the function bound to the passed in delegate instance
         delegateProgressType();
     }
 }