显示进度条上完成的工作百分比 [英] Show Percentage of work accomplished on Progress bar
本文介绍了显示进度条上完成的工作百分比的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Hello All,
我需要使用该线程显示方法DoLongWork()在进度条中完成的工作百分比。
Hello All,
I need to show the percentage of the work done by method DoLongWork() in a Progressbar using the thread.
Public string DoLongWork(int varName)
{
Thread.Sleep(1000000);
/*This method will take 1 hour to return the result (say)*/
Return "Done";
}
任何类型的建议都将受到高度赞赏。谢谢,Anil
问候,
Anil
Any type of suggestion will be highly appreciated. Thanks, Anil
Regards,
Anil
推荐答案
请看我的评论这个问题。答案取决于太多因素:1)您如何估计工作的百分比(基于迭代次数,时间估计等)? 2)你的UI库是什么。如果你建议一个更现实的例子,它可以帮助你获得更有效的帮助。
同时请学习一些基本问题的基础知识。这与UI线程调用有关:调用
或BeginInvoke
。请查看我过去的答案:
Control.Invoke( )与Control.BeginInvoke() [ ^ ],
Treeview扫描仪和MD5的问题 [ ^ ]。
-SA
Please see my comment to the question. The answer depends on too factors: 1) how can you estimate the percentage of the work (based on number of iterations, time estimate, etc)? 2) what is your UI library. If you suggest a more realistic example, it can help you to get more productive help.
In the meanwhile please learn some basics fundamental to this problem. This is related to UI thread invocation:Invoke
orBeginInvoke
. Please see my past answers:
Control.Invoke() vs. Control.BeginInvoke()[^],
Problem with Treeview Scanner And MD5[^].
—SA
>
这篇关于显示进度条上完成的工作百分比的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文