本文介绍了Application.Exit()无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Exit();
            Application.Run(new Form1());
        }

为什么在调用Application.Exit()之后,应用程序没有立即退出?在此行之后,仍然显示Form1.如何立即退出应用程序.谢谢.

Why after calling Application.Exit(), application doesn't exit immediately? After this line, Form1 still shows. How to exit application immediately. Thanks.

* 注意: *这仅是示例.在显示表单之前,我会处理一些功能.在函数中,我有一个命令代码来调用Application.Exit(),但我想知道为什么应用程序不会立即退出.

*Notes:*this is only an example. I handle some functions before showing form. And in functions, I have a command code to call Application.Exit() but I wonder why application doesn't exit immediately.

我正在使用.NET Framework 4.0

I'm using .NET Framework 4.0

推荐答案

应用程序.退出说:

问题在于,直到您调用运行"并创建表单之后,您的应用程序的消息泵才会启动.

The problem is the message pump for your application wont start until after you call Run and the Form is created.

这篇关于Application.Exit()无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 06:11
查看更多