C#表单保持“冻结"状态.当我在活动应用程序之间切换时 [英] C# form keeps "freezing" when I toggle between active applications

查看:74
本文介绍了C#表单保持“冻结"状态.当我在活动应用程序之间切换时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个基于.NET 2.0的c#winform应用程序.简而言之,该应用程序以表格形式接收大量用户输入,并运行一些业务逻辑,并创建3个输出文件,这些文件保存在用户的PC上.

输入信息后,用户单击执行"按钮,将打开一个新表单,告诉用户请在应用程序运行时等待".幕后:加载请稍候"表单后,它将触发后台工作程序创建文件. RunWorkerCompleted告诉请稍候"表单关闭并通知用户它已完成.

问题:如果我运行该应用程序并继续专注于该应用程序,那么一切都会正常进行.但是,如果我运行该应用程序,然后将焦点切换到另一个应用程序(即查看我的电子邮件),然后再切换回我的应用程序,则它在请稍候"屏幕上保持冻结状态.

希望我对此描述足够好...请让我知道您认为可能会发生什么,或者您认为我的设计可能有缺陷.在此先感谢您!

I have a c# winform app built on .NET 2.0. In a nutshell, the app takes a bunch of user input in a form and runs some business logic and creates 3 output files that are saved on the user''s pc.

Once information is input and the user clicks the "go" button, a new form is opened telling the user to "please wait while the app is working." Behind the scenes: once the "please wait" form is loaded, it triggers the background worker to create the files. The RunWorkerCompleted tells the "please wait" form to close and notify the user that it is complete.

The problem: If I run the application and keep focus on the app, everything works well. However, if I run the app, then switch focus to another app (i.e. look at my email) then switch back to my application, it stays frozen on the "please wait" screen.

Hopefully I described this well enough... please let me know what you think might be going on or if you think my design might be flawed. Thanks in advance!

推荐答案

您是否正在使用 Control.Invoke [^ ]从工作线程与GUI线程进行通信?如果不是,那可能就是您的问题.

问候
Espen Harlinn
Are you using Control.Invoke[^] to communicate from the worker thread to the GUI thread? If you''re not that might be your problem.

Regards
Espen Harlinn


这篇关于C#表单保持“冻结"状态.当我在活动应用程序之间切换时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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