[C] 纯文本查看 复制代码
///
/// 执行耗时操作
///
///
///
private void backgroundProjectIssues_DoWork(object sender, DoWorkEventArgs e)
{
try
{
e.Result = false;
//repositoryItemProgressBar2 进度条
this.repositoryItemProgressBar2.ShowTitle = true;
//this.repositoryItemProgressBar2.Step = 1;
this.repositoryItemProgressBar2.LookAndFeel.SkinMaskColor = Color.LawnGreen;
this.repositoryItemProgressBar2.Maximum = 100000;
this.repositoryItemProgressBar2.Minimum = 0;
this.barEditItem_status.EditValue = 0;
int sum=0;
for(int i=0;i<100000;i++){
//计算
sum+=i;
#region 报告进度
// this.barEditItem_status.EditValue = i;
message = "进度条显示信息" + i;
//ReportProgress 方法把信息传递给 ProcessChanged 事件处理函数。
//第一个参数类型为 int,表示执行进度。
//如果有更多的信息需要传递,可以使用 ReportProgress 的第二个参数。
//这里我们给第二个参数传进去一条消息。
this.backgroundProjectIssues.ReportProgress(i, message);
#endregion
}
}catch (System.Exception ex)
{
//捕获异常
}
}
///
/// 报告进度
///
///
///
private void backgroundProjectIssues_ProgressChanged(object sender, ProgressChangedEventArgs e)
{
//修改进度条的显示。 //barEditItem是DEvExprress的一个进度条控件
this.barEditItem_status.EditValue = e.ProgressPercentage;
//如果有更多的信息需要传递,可以使用 e.UserState 传递一个自定义的类型。
//这是一个 object 类型的对象,您可以通过它传递任何类型。
string message = e.UserState.ToString();
this.barEditItem_status.Caption = message;
}
///
///
///
///
///
private void backgroundProjectIssues_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
try
{
if ((bool)e.Result)
{
MessageBox.Show("耗时操作完成!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
catch (System.Exception ex)
{
}
}