Exemplo n.º 1
0
        private void bgwConvert_DoWork(object sender, DoWorkEventArgs e)
        {
            //将各参数拆箱
            List <string> xlsFiles = (List <string>)e.Argument;

            //进度条前期空
            //int beforeSpan = 10;
            //进度条后期空
            //int afterSpan = 10;

            //先显示一点进度条
            //bgwConvert.ReportProgress(beforeSpan);

            for (int i = 0; i < xlsFiles.Count; i++)
            {
                //取消当前操作
                if (bgwConvert.CancellationPending)
                {
                    e.Cancel = true;

                    return;
                }

                CommandLineProcess command = new CommandLineProcess(new Dictionary <string, string> {
                    { "xlsFile", xlsFiles[i] }
                });
                command.Process();

                //报告进度
                //bgwConvert.ReportProgress(beforeSpan + (i + 1) * (100 - beforeSpan - afterSpan) / xlsFiles.Count);
            }

            //bgwConvert.ReportProgress(100 - afterSpan);
            //稍微暂停一下,以表现满格前最后一步动作
            //Thread.Sleep(1000);

            //进度条满格
            //bgwConvert.ReportProgress(100);
            //稍微暂停一下,以表现满格
            //Thread.Sleep(500);
        }
Exemplo n.º 2
0
        private void bgwConvert_DoWork(object sender, DoWorkEventArgs e)
        {
            //将各参数拆箱
            List<string> xlsFiles = (List<string>)e.Argument;

            //进度条前期空
            //int beforeSpan = 10;
            //进度条后期空
            //int afterSpan = 10;

            //先显示一点进度条
            //bgwConvert.ReportProgress(beforeSpan);

            for (int i = 0; i < xlsFiles.Count; i++)
            {
                //取消当前操作
                if (bgwConvert.CancellationPending)
                {
                    e.Cancel = true;

                    return;
                }

                CommandLineProcess command = new CommandLineProcess(new Dictionary<string, string> { { "xlsFile", xlsFiles[i] } });
                command.Process();

                //报告进度
                //bgwConvert.ReportProgress(beforeSpan + (i + 1) * (100 - beforeSpan - afterSpan) / xlsFiles.Count);
            }

            //bgwConvert.ReportProgress(100 - afterSpan);
            //稍微暂停一下,以表现满格前最后一步动作
            //Thread.Sleep(1000);

            //进度条满格
            //bgwConvert.ReportProgress(100);
            //稍微暂停一下,以表现满格
            //Thread.Sleep(500);
        }