数据从SQL下载到XML时,Windows窗体中的进度条形成应用程序 [英] Progress bar in windows form application when data downloading from SQL to XML

查看:87
本文介绍了数据从SQL下载到XML时,Windows窗体中的进度条形成应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



请帮我找到这个,我将在3天内第二次发布此问题。



in我的Windows应用程序按钮单击我将数据从SQL数据库下载到XML文件,下载需要8到10秒,在那段时间我想在UI中显示进度条。



i尝试了很多方法



1)我尝试使用此链接中的BackgroundWorker http://eclipsed4utoo.com/blog/windows-form-progressbar/ [ ^ ]



2)我使用线程概念和Begin调用方法



3)并且还使用简单的计时器来更新进度条



每次进度条显示数据下载完成后的状态。

我想在数据从在线下载到xml时显示进度条/>


以上所有方法都没有完美的工作,请帮助我。



我发布的相同问题的链接3天后在Windows窗体应用程序中显示进度条 [ ^ ]

推荐答案

您不从后台线程更新进度条值。您可以在后台线程中下载数据,然后告诉UI线程更新进度条。 UI控件不能以任何方式从后台线程触及。



此外,如果这将完全起作用完全取决于您的数据库下载代码。我们根本没有看到这一点,如果没有这个,就不可能告诉你,如果你在那里做错了会违反进度条的目的。
You don't update the progressbar value from a background thread. You do the WORK of downloading the data in the background thread and then tell the UI thread to update the progressbar. UI controls can NOT be touched in any way from a background thread.

Also, if this is going to work at all depends entirely on your "database download" code. We haven't seen that at all and without that, it's impossible to tell you if you're doing something wrong there that defeats the purpose of a progressbar.


这篇关于数据从SQL下载到XML时,Windows窗体中的进度条形成应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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