如何在Windows C#应用程序中停止不响应消息 [英] How to stop Not Responding Message in windows c# application

查看:98
本文介绍了如何在Windows C#应用程序中停止不响应消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我单击按钮代码时,代码可以正确执行,但需要花费一些时间,并且表单标题栏中会出现"Not Responding Message"(不响应消息).

When i click on button code executes correct but takes some time and " Not Responding Message" appears at form title bar

推荐答案

您的应用程序是单线程的.当它运行任务时,没有线程可以继续响应Windows消息.如果您在另一个线程中执行任务,则在运行该消息时将看不到该消息.较便宜的选择是在应用程序正在运行的任何循环内添加Application.DoEvents()行,这将导致它每次到达那里时都处理消息.
Your application is single threaded. While it is running it''s task, there is no thread to keep responding to windows messages. If you perform your task in another thread, then you won''t see that message while it is running. A cheaper option is to add the line Application.DoEvents() inside whatever loops your app is running, which will cause it to process messages each time it gets there.


这篇关于如何在Windows C#应用程序中停止不响应消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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