Пример #1
0
        // is only for updating progressbar data
        // object:  has to be an instance of Progressbar
        private void ProgressBarThread(object pb)
        {
            Progressbar progressBar = (Progressbar)pb;

            while (Progress < ProgressEnds)
            {
                progressBar.SetValue(Progress);
                Thread.Sleep(100);
            }

            // Thread synchronisation to close the Progressbar
            if (progressBar.InvokeRequired)
            {
                progressBar.BeginInvoke((MethodInvoker)progressBar.Close);
            }
            else
            {
                progressBar.Close();
            }
        }