进度条更新出现问题 [英] problems with the progress bar updating

查看:74
本文介绍了进度条更新出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好.请原谅我,如果已经回答了,但是我在进度栏上进行了搜索,结果超过了500万.因此,与其花费我的余生进行搜索,不如再次提出这个问题.我有一个使用Windows窗体的VB.net应用程序 进度条.问题是我可以将最大值设置为一个值,当达到该值时进度栏将无法完成.有时是一半,有时是四分之三,但从未完全充满.有人对此有任何答案吗?

hello all. Pardon me if this is already been answered but I did a search on progress bar and there are over 5 million results. So rather than spend the rest of my life searching all asked this question again. I have a VB.net application using a Windows forms progress bar. The problem is I can set the maximum to a value and when that value is reached the progress bar is not completed. Sometimes it's halfway sometimes is three quarters of the way but never completely filled. Anyone have any answers to this?

谢谢

推荐答案

这可能是由于有很多东西同时发生在主线程上,并且进度条的绘制没有系统资源的优先级.您可以使用System.ComponentModel.BackgroundWorker来帮助解决此问题 对象执行首先需要进度条的密集操作.可能有...嗯,有500万个在线使用后台工作人员的示例-该类的MSDN示例是一个好的开始: http://msdn.microsoft.com/zh-cn/library/system.componentmodel.backgroundworker.aspx

This is probably due to the fact that there are many things happening on the main thread concurrently and the painting of the progress bar is not given the priority by the system resources.  You can help this by using a System.ComponentModel.BackgroundWorker object to perform the intensive operation that requires the progress bar in the first place.  There are probably...  well, five million example of using a background worker online -- the MSDN example for the class is a good start:  http://msdn.microsoft.com/en-us/library/system.componentmodel.backgroundworker.aspx

如果您已经在使用后台工作程序,但仍然遇到问题,或者您不想尝试,可以尝试使用一些蛮力手段,即明确要求进度条进行自我更新.这可以通过调用 进度条上的Refresh()方法.实际上,此功能可以在所有控件上找到,对于问题较多的Application.DoEvents调用,它是首选的,更实用的技术,DoEvents调用可清除所有控件的整个消息队列. (以及更多).

If you are already using a background worker but are still having issues or else you don't want to attempt it you could try something a little brute force which is to explicitly ask the progress bar to update itself.  This can be done by calling the Refresh() method on teh progress bar.  In fact, this function can be found on all controls and is a much preferred and more surgical technique to the more problematic Application.DoEvents call which clears the entire message queue for all the controls (and more).


这篇关于进度条更新出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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