winform程序,用来实现导数,并显示进度与执行情况,界面如下:
![](https://www.cnblogs.com/images/cnblogs_com/semye/screen1.jpeg)
页面级代码如下:
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
delegate void ExcuteDelegate();
private void button1_Click(object sender, System.EventArgs e)
{
ExcuteDelegate dlg = new ExcuteDelegate(this.DoLeadData);
dlg.BeginInvoke(null,null);
}
/// <summary>
/// 导入数据
/// </summary>
/// <returns></returns>
public void DoLeadData()
{
Bll.LeadData bl = new Bll.LeadData();
DataSet dsMain = new DataSet();
int i=0;
ArrayList alClass = new ArrayList();
Model.Status mdst = new Model.Status();
//取主表RouteMainInfo数据
dsMain = bl.GetMainData();
//取记录总数
int count = dsMain.Tables[0].Rows.Count;
bl.ChangStatus(mdst,"",count);
// ChangStatus(mdst,"",count);
if(count>0)
{
for(i=6;i<100;i++)
{
bl.DoLead(i,mdst,dsMain);
this.ViewDoing();
}
}
}
private void ViewDoing()
{
Model.Status md = new Model.Status();
this.label2.Text = md.total.ToString();
this.label4.Text = md.finish.ToString();
this.label6.Text = md.success.ToString();
this.label8.Text = md.fail.ToString();
this.progressBar1.Maximum=md.total;
this.progressBar1.Minimum=0;
this.progressBar1.Value = md.finish;
}
其中 BLL层的方法DoLead(……)是实现导数的核心方法,方法ViewDoing()用来在界面显示当前执行状态,原来方法DoLeadData()是放在BLL层中,方法ViewDoing()在页面级,问题是这样达不到界面同步显示程序执行进度的效果,所有才把
for(i=6;i<100;i++)
{
bl.DoLead(i,mdst,dsMain);
this.ViewDoing();
}
以外的代码提到页面级来,把 this.ViewDoing()放到循环体进去,才达到我要结果,我想问一下,如何让这个FOR循环在BLL层执行,而又能实现我要的效果?
请高手指点!![](https://www.cnblogs.com/CuteSoft_Client/CuteEditor/images/emteeth.gif)
![](https://www.cnblogs.com/images/cnblogs_com/semye/screen1.jpeg)
页面级代码如下:
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
其中 BLL层的方法DoLead(……)是实现导数的核心方法,方法ViewDoing()用来在界面显示当前执行状态,原来方法DoLeadData()是放在BLL层中,方法ViewDoing()在页面级,问题是这样达不到界面同步显示程序执行进度的效果,所有才把
for(i=6;i<100;i++)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
以外的代码提到页面级来,把 this.ViewDoing()放到循环体进去,才达到我要结果,我想问一下,如何让这个FOR循环在BLL层执行,而又能实现我要的效果?
请高手指点!
![](https://www.cnblogs.com/CuteSoft_Client/CuteEditor/images/emteeth.gif)