显示进度直到操作完成 winform
我有一个 WinForm 应用程序(.net 3.5),当您第一次选择一个人时,它会检索整个计划的所有该人的数据。这可能需要最多 5 秒。我需要向我的用户(仅限内部)展示程序正在以某种方式加载/工作。我还需要将它们保留在该屏幕上,直到它也完成。根据应用程序的设计,他们可以跳转到应用程序中的任意数量的位置。
我想也许 Background Worker
就是我想要的,但因为我希望它们留在原处直到加载,所以我不再确定(???)。
我的应用程序正在做的是填充 ~ 20 个用户控件。每个用户控件都会查询本地 SQL Express DB 以获取其信息。因此,我的父表单上有一个方法,可以遍历并“绘制”所有用户控件,这就是他们所等待的。
有想法吗?我最好的选择是什么。
I have a WinForm app(.net 3.5) that when you first select a Person it retrieves all of that persons data for there entire Plan. This can take up to 5 secs. I need to show my users(in house only) that the program is loading/working in some way. I also need to keep them at that screen until it finishes as well. Do to the design of the app they could jump to any number of places in the App.
I thought maybe a Background Worker
is what I want but because I want them to stay where they are until it loads I am no longer sure(???).
What my App is doing is populating ~ 20 User Controls. Each User Control queries a Local SQL Express DB for it's information. So I have a method on my Parent Form that goes through and 'Paints' all the User Controls and that is what they are waiting for.
Ideas? What's my best bet.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以创建一个带有进度条的 ProgressBarForm。执行 ShowDialog 使其成为模式。
并订阅BackgroundWorker的ReportProgress来让你的进度条进度。
You could create a ProgressBarForm that has a progress bar. Do a ShowDialog to make it modal.
And subscribe to the ReportProgress of the BackgroundWorker to make your progress bar progress.
BackgroundWorker
是一个不错的选择,那就去做吧 - 它是为您描述的场景而设计的。BackgroundWorker
is a sound choice, go for it - it's designed for scenarios such as you describe.带有进度条的锁定模态窗口怎么样,该进度条会随着后台工作人员抛出的事件而变化? Winforms 确实不是我的菜,但类似的东西可以工作。
How about a locked modal window with a progressbar that changes on events thrown by the backgroundworker? Winforms isn't really my bag but something like this could work.