コード例 #1
0
        private delegate void DoDataDelegate(object StepValue);//创建委托

        /// <summary>
        /// 进度循环
        /// </summary>
        /// <param name="StepValue"></param>
        private void DoData(object StepValue)
        {
            try
            {
                if (ExcelProgBar.InvokeRequired)
                {
                    DoDataDelegate doDelgt = DoData;
                    ExcelProgBar.Invoke(doDelgt, StepValue);
                }
                else
                {
                    //循环执行当前进度
                    ExcelProgBar.Maximum = (int)StepValue;
                    for (int i = 0; i < (int)StepValue; i++)
                    {
                        ExcelProgBar.Value = i;
                        int PercMsg = i * 100 / (int)StepValue;
                        lblPercent.Text = PercMsg.ToString() + "%";
                        Thread.Sleep(100);
                        Application.DoEvents();
                    }
                    //ProgressThread.Abort();//关闭线程
                    //Environment.Exit(0);
                    this.Close();
                }
            }catch (Exception ex)
            {
                MessageBoxEx.Show(ex.Message, "异常提示", MessageBoxButtons.OK, MessageBoxIcon.Question);
            }
        }
コード例 #2
0
        /// <summary>
        /// 进行循环
        /// </summary>
        /// <param name="StepValue">进度值</param>
        private void DoData(object StepValue)
        {
            try
            {
                if (ExcelProgBar.InvokeRequired)
                {
                    DoDataDelegate DDelgt = DoData;
                    ExcelProgBar.Invoke(DDelgt, StepValue);
                }
                else
                {
                    ExcelProgBar.Maximum = (int)StepValue;//获取当前最大值

                    for (int i = 0; i < (int)StepValue; i++)
                    {
                        lblPercent.Text    = ProgressValue; //获取进度百分比
                        ExcelProgBar.Value = CurrentValue;  //获取当前进度
                        Application.DoEvents();
                    }
                    MessageBoxEx.Show("导出成功!");
                }
            }
            catch (Exception ex)
            {
                MessageBoxEx.Show(ex.Message);
            }
        }
コード例 #3
0
ファイル: frmSmartClient.cs プロジェクト: BsJia/WeightManager
 private void DoData(object number)
 {
     if (skinProgressBar1.InvokeRequired)
     {
         DoDataDelegate d = DoData;
         skinProgressBar1.Invoke(d, number);
     }
     else
     {
         skinProgressBar1.Value = (int)number;
     }
 }
コード例 #4
0
ファイル: RollWait.cs プロジェクト: xinqishiyin/BR300-
 /// <summary>
 /// 进行循环
 /// </summary>
 /// <param name="number"></param>
 private void DoData(object number)
 {
     if (progressBar1.InvokeRequired)
     {
         DoDataDelegate d = DoData;
         progressBar1.Invoke(d, number);
     }
     else
     {
         progressBar1.Maximum = (int)number;
         for (int i = 0; i < (int)number; i++)
         {
             progressBar1.Value = i;
             Application.DoEvents();
         }
         //循环结束截止时间
     }
 }
コード例 #5
0
        void DoData()
        {
            if (progressBar1.InvokeRequired)
            {
                DoDataDelegate d = DoData;
                progressBar1.Invoke(d);
            }
            else
            {
                AddInfoMessage("*****BEGIN " + DateTime.Now.ToString());
                string[] fn = Directory.GetFiles(ExcelPath.Text, "*.xls*");
                progressBar1.Maximum = fn.Length;

                DataExport de = new DataExport();
                de.CodePath = codePath.Text;
                de.JsonPath = JsonPath.Text;
                de.OType    = OType;

                foreach (var file in fn)
                {
                    if (bStop)
                    {
                        break;
                    }

                    if (!Path.GetFileName(file).Contains("$"))
                    {
                        AddInfoMessage("Handle " + file);
                        de.Work(file);
                    }
                    progressBar1.Value = progressBar1.Value + 1;
                    Application.DoEvents();
                }
                bProcessing        = false;
                progressBar1.Value = progressBar1.Maximum;
                AddInfoMessage("*****END  " + DateTime.Now.ToString());
            }
        }
コード例 #6
0
 /// <summary>
 /// 循环显示导入进度
 /// </summary>
 /// <param name="StepValue"></param>
 private void DoDataProgress(object MaxValue)
 {
     if (ProgBar.InvokeRequired)
     {
         DoDataDelegate DoDelgt = DoDataProgress;
         ProgBar.Invoke(DoDelgt, MaxValue);
     }
     else
     {
         ProgBar.Maximum = (int)MaxValue;
         for (int i = 0; i < (int)MaxValue; i++)
         {
             int CurPercent = 0;
             ProgBar.Value   = i;
             CurPercent      = i * 100 / (int)MaxValue;
             lblPercent.Text = CurPercent.ToString() + "%";
             //Thread.Sleep(5);
             Application.DoEvents();
         }
         lblPercent.Text = "100%";
         ProgressThread.Abort();//终止线程
         this.Close();
     }
 }