Ejemplo n.º 1
0
        private void handleProgressBar()
        {
            //valore di partenza
            double value = pBar.Value;
            //istanza delegate per puntare almetodo richiesto.
            updateProgressBarDelegate updateProgressBar = new updateProgressBarDelegate(pBar.SetValue);

            //finchè non raggiunge il valore massimo incrementa
            while (!(pBar.Value == pBar.Maximum))
            {
                value += 1;
                //invova il delegate con thread a priorità bassa.
                Dispatcher.Invoke(updateProgressBar,
                                  System.Windows.Threading.DispatcherPriority.Background,
                                  new object[] { ProgressBar.ValueProperty, value });
            }
        }
Ejemplo n.º 2
0
        private void handleProgressBar()
        {
            //valore di partenza
            double value = pBar.Value;
            //istanza delegate per puntare almetodo richiesto.
            updateProgressBarDelegate updateProgressBar = new updateProgressBarDelegate(pBar.SetValue);
            //finchè non raggiunge il valore massimo incrementa
            while (!(pBar.Value == pBar.Maximum))
            {
                value += 1;
                //invova il delegate con thread a priorità bassa.
                Dispatcher.Invoke(updateProgressBar, 
                    System.Windows.Threading.DispatcherPriority.Background,
                    new object[] { ProgressBar.ValueProperty,value });
            }

        }
Ejemplo n.º 3
0
        public static void UpdateProgressBar(ProgressBar progressBar, int max, int value)
        {
            if (progressBar.InvokeRequired)
            {
                updateProgressBarDelegate del = new updateProgressBarDelegate(UpdateProgressBar);
                progressBar.Invoke(del, new object[] { progressBar, max, value });
            }
            else
            {
                if ((max == 0) && (value == 0))
                {
                    progressBar.Visible = false;

                }
                else
                {
                    if (max != 0)
                        progressBar.Maximum = max;

                    progressBar.Value = value;
                }
            }
        }
Ejemplo n.º 4
0
 public void updateTracking(int id, int percent, string bname, string status = "")
 {
     refreshTrackingDelegate = new updateProgressBarDelegate(() => { refreshTracking(id, percent, bname, status); });
     Invoke(refreshTrackingDelegate);
 }
Ejemplo n.º 5
0
 private void updateProgressBar(int x, ProgressBar l)
 {
     if (l.InvokeRequired)
     {
         // this is worker thread
         updateProgressBarDelegate del = new updateProgressBarDelegate(updateProgressBar);
         l.Invoke(del, new object[] {x, l });
     }
     else
     {
         // this is UI thread
         if (x > 100)
         {
             x = 100;
         }
         l.Value = x;
     }
 }