本文介绍了如何为线程设置进度条的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一个帖子中创建了一个很长的过程......就像这样



i am created a long process in a thread ....like this

private void task1()
{
//a long process i don't know when this process end.
}





按钮点击_________________________________



on button click________________________________________

Thread longprocess = new Thread(task1);
                longprocess.IsBackground = true;
                longprocess.Start();







如何为此设置进度条线程......




How can i set a progress bar for this thread......

推荐答案



/// <summary>
///   Update the work item state counts.
/// </summary>
private void RefreshCounts()
{
    if (this.InvokeRequired)
    {
        MethodInvoker mi = new MethodInvoker(RefreshCounts);
        this.BeginInvoke(mi);
    }
    else
    {
        lock (this)
        {
            progressBar1.Value = ProgressDownload;
        }
    }


}







godd运气



jeremy




godd luck

jeremy


这篇关于如何为线程设置进度条的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 06:25