本文介绍了MessageBox在进度条完成其工作之前显示消息....的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题是在进度条完成之前显示Messagebox。看下面的代码



 private void Form1_Load(object sender,EventArgs e)
{
bgw.RunWorkerAsync() ;
}

private void bgw_DoWork(object sender,DoWorkEventArgs e)
{
for(int i = 0; i< = count; i ++)
{
bgw.ReportProgress((i * 100)/ count);
}
}

private void bgw_ProgressChanged(object sender,ProgressChangedEventArgs e)
{
progressBar1.Value = e.ProgressPercentage;
}

private void bgw_RunWorkerCompleted(object sender,RunWorkerCompletedEventArgs e)
{
Application.DoEvents();
MessageBox.Show(Succcesfully Updated);
}
解决方案

My problem is Messagebox is displaying before progress bar finished. see the below code

private void Form1_Load(object sender, EventArgs e)
{
    bgw.RunWorkerAsync();
}

private void bgw_DoWork(object sender, DoWorkEventArgs e)
{
    for (int i = 0; i <= count; i++)
    {
        bgw.ReportProgress((i * 100) / count);
    }
}

private void bgw_ProgressChanged(object sender, ProgressChangedEventArgs e)
{
    progressBar1.Value = e.ProgressPercentage;
}

private void bgw_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
    Application.DoEvents();
    MessageBox.Show("Succcesfully Updated");
}
解决方案


这篇关于MessageBox在进度条完成其工作之前显示消息....的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-21 09:08