如何显示进度条以了解未知的处理时间 [英] How to show progressbar for unknown process time

查看:366
本文介绍了如何显示进度条以了解未知的处理时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

先生
我是uday satardekar

在我的c敏锐winform应用程序中,我试图显示进度条以显示长时间运行的过程,这需要一分钟以上.

但是这次是未知的.所以我如何显示进度条
谢谢.........

Sir
I am uday satardekar

In my c sharp winform application,i am trying to show progressbar for long running process which take more than one minute.

But this time is unknown.so how i can show progressbar for that
Thanks .........

推荐答案

链接对您有帮助-
http://social.msdn.microsoft.com/Forums/zh/csharpgeneral/thread/80d0f0d9-c077-429d-8830-5f97771f5e03 [ http://www.codeguru.com/forum/showthread.php?t=404051 [ ^ ]
Couple of links to help you out -
http://social.msdn.microsoft.com/Forums/en/csharpgeneral/thread/80d0f0d9-c077-429d-8830-5f97771f5e03[^]
http://www.codeguru.com/forum/showthread.php?t=404051[^]


回应您在解决方案1中的评论,这是我的解决方案...

本质上,您只需将工具箱中的后台工作人员拖放到窗体上,然后挂接事件并根据需要设置属性.在按钮单击处理程序中,您告诉后台工作人员启动,并使用其ReportProgress向UI线程报告进度.

由于持续时间是不确定的,因此可以在进度条上设置适当的样式...或者您可能会以某种方式尝试找到一种方法来估计所需的时间.例如,您可能会使用花费一些时间来执行一些初始步骤,并使用某种比率来估算总时间.再添加5%,如果最后仍未完成,请再次将进度条设置为不确定状态.

所有步骤均在此处明确说明.尽管该示例是Silverlight的示例,但在WinForms上基本上是相同的(但您可以通过设计器来挂接事件).

如何:使用后台工作者 [
In response to your comment in Solution 1, here is my solution...

Essentially, you simply drop a background worker from the toolbox unto the the form and then hook up events and set properties as required. In your button click handler, you tell your background worker to start and you use its ReportProgress to report progress to the UI thread.

Since your duration is inderminate, you can set the appropriate style on the progress bar... or you might somehow try to find a way to estimate how long it would take. For example, you might uses the time taken to do some initial step and uses some ratio to estimate the total time. Add an extra 5% to that and if at the end of time, it is still not completed, set the progress bar in the indeterminated state again.

All steps are clearly explained here. Although that example if for Silverlight, it is essentially the same on WinForms (but you can hook events with the designer).

How to: Use a Background Worker[^]


这篇关于如何显示进度条以了解未知的处理时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆