C#,应用程序不会终止 [英] C#, Application does not terminate

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

问题描述

大家好,


我的问题是当我使用标题栏上的关闭框关闭表单时应用程序没有终止。实际上似乎程序已关闭,但任务管理器的进程列表显示它不是。

有一个线程是我在表单加载事件中手动创建和启动的。但我将线程的IsBackground属性设置为true。因此,它应该在退出应用程序时终止。

还有其他线程可以刷新表单上的网格。由于我使用的是2.0框架,因此我将表单的CheckForIllegalCrossThreadCalls属性设置为false以避免异常。问题可能取决于此吗?

奇怪的是我在电脑上没有遇到这个问题。在我的计算机上,应用程序成功终止。

Hi all,

my problem is that the application doesn''t terminate when I close the form using the close box on the caption bar. Actually it seems as if the program is closed but task manager''s process list shows that it is not.
There is one thread that I manully create and start in forms load event. But I set the IsBackground property of the thread to true. So, it should terminate while exiting the application.
There are other threads that refresh the grids on my form. Since I am using 2.0 framework, I set the CheckForIllegalCrossThreadCalls property of the form to false to avoid exceptions. Can the problem depend on this?
The weird thing is that I don''t encounter this problem on my computer. On my computer the application terminates successfully.

推荐答案

您是否尝试过使用应用程序卸载事件?
Have you tried using the application unload event?


尝试定义线程你正在手动创建后台工作程序,

定义线程时


线程t =新线程(新线程启动(函数));

t.IsBackground = true;

t.Start();


检查...我不是shure该属性被命名IsBackGround,它说的是这样的......但是当主线完成时,用该属性激活该线程完成。


我喜欢它可以帮助你:D


享受你的一天:D
Try defining the thread you are creating manually as a Background worker,
when you define the thread

thread t = new thread(new threadstart(function));
t.IsBackground = true;
t.Start();

check that.. I''m not shure the property is named IsBackGround, it says something like that.. but with that property activate that thread finishes when the main thread finish.

I hopy it helps you :D

enjoy your day :D


谢谢乔治,但这正是我所做的。

它适用于我的电脑。但是当我在另一台计算机上测试我的应用程序时,线程继续工作该计算机上没有.NET框架。但我把框架放在了安装项目中。可能问题取决于它吗?


谢谢kenobewan。但我没有看到使用应用程序卸载事件的重点。你能解释一下吗?
Thank you george, but it is exactly what I do.
It works on my computer. But a thread continues working when I test my application on another computer. There is no .NET framework on that computer. But I put the framework in setup project. May the problem depends on it ??

Thank you kenobewan. But I don''t see the point in using application unload event. Can yo explain it please?


这篇关于C#,应用程序不会终止的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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