在长时间运行的任务Winform的更新 [英] Winform updates on long running tasks

查看:210
本文介绍了在长时间运行的任务Winform的更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你有保持'画',而应用程序正在执行一个长期运行的任务?

Do you have a good solution for keeping a 'Please wait' winform 'painted' while an application is performing a long running task ?

我已经尝试用请等待的winform一个很好的解决方案form.refresh()上的每个步骤,但也有发生,这意味着这是不够频繁几个长时间运行的查询。

I've tried using form.refresh() on each step, but there are a few long running queries that take place, which means that this isn't frequent enough.

基本上,这<一HREF =http://stackoverflow.com/questions/148963/keeping-guis-responsive-during-long-running-tasks> SO通过VSTO(而不是Python中)询问但是,在C#在Excel中。

Basically this SO Question but, on C# in Excel through VSTO (rather than Python).

推荐答案

这里有一个很好的例子的在C#代码。

这是一个启动画面特别,但它几乎是相同的过程(也许减去一些华而不实的不透明度)来创建一个请等待窗口。

It is for splash screens specifically, however it is almost identical process (perhaps minus some of the flashy Opacity) to create a Please wait window.

关键信息,您将需要一个单独的线程。这可以但文章给出了如何正确地做一个好覆盖/例如复杂的事情。

The key information is that you will need a separate thread. This can complicate things however the article gives a good coverage/example of how to do it correctly.

这篇关于在长时间运行的任务Winform的更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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