c\s winfroms: 点击窗体关闭按钮,程序没有退出?

lvg 2008-11-19 03:49:26
c\s winfroms: 点击窗体关闭按钮,窗体关闭了,但在任务管理器里的.exe程序还在。
怎么解决? 谢谢!
...全文
162 17 打赏 收藏 转发到动态 举报
写回复
用AI写文章
17 条回复
切换为时间正序
请发表友善的回复…
发表回复
lvg 2008-11-19
  • 打赏
  • 举报
回复
呵呵

谢谢 我在仔细看看!
RexZheng 2008-11-19
  • 打赏
  • 举报
回复
CSDN真慢,N久发不出去,结果一下全发上去了
RexZheng 2008-11-19
  • 打赏
  • 举报
回复
[Quote=引用 12 楼 lvg 的回复:]
引用:using System.Diagnostics;

编译可以了, 但测试.exe 还存在任务管理器中
[/Quote]

如果你执行 Process.GetCurrentProcess().Kill(); 没有出错,而进程还在任务管理器中,那那个进程应该不是你现在运行的这个了,你可以用进程ID对比一下,可能是你之前做测试的时候留下来的。
RexZheng 2008-11-19
  • 打赏
  • 举报
回复
[Quote=引用 12 楼 lvg 的回复:]
引用:using System.Diagnostics;

编译可以了, 但测试.exe 还存在任务管理器中
[/Quote]

如果你执行 Process.GetCurrentProcess().Kill(); 没有出错,而进程还在任务管理器中,那那个进程应该不是你现在运行的这个了,你可以用进程ID对比一下,可能是你之前做测试的时候留下来的。
RexZheng 2008-11-19
  • 打赏
  • 举报
回复
[Quote=引用 12 楼 lvg 的回复:]
引用:using System.Diagnostics;

编译可以了, 但测试.exe 还存在任务管理器中
[/Quote]

如果你执行 Process.GetCurrentProcess().Kill(); 没有出错,而进程还在任务管理器中,那那个进程应该不是你现在运行的这个了,你可以用进程ID对比一下,可能是你之前做测试的时候留下来的。
lvg 2008-11-19
  • 打赏
  • 举报
回复
引用:using System.Diagnostics;

编译可以了, 但测试.exe 还存在任务管理器中
RexZheng 2008-11-19
  • 打赏
  • 举报
回复

System.Diagnostics.Process.GetCurrentProcess().Kill();
或者
using System.Diagnostics;
lvg 2008-11-19
  • 打赏
  • 举报
回复
0009:

编译: 当前上下文中不存在名称“Process”
RexZheng 2008-11-19
  • 打赏
  • 举报
回复


[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
Process.GetCurrentProcess().Kill();
}

RexZheng 2008-11-19
  • 打赏
  • 举报
回复
有线程没退出,还在运行。
fuyuxin19801120 2008-11-19
  • 打赏
  • 举报
回复
调用dispose方法
lvg 2008-11-19
  • 打赏
  • 举报
回复
帮看下:


static class Program
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Login());
}
}



//登陆窗体代码
private void toolStripButton2_Click(object sender, EventArgs e)
{
this.Hide();
LoginForm lg = new LoginForm();
lg.Show();
}


//把弹出的窗体关闭,管理里还留着登陆窗体的.exe
bbbbbb888888 2008-11-19
  • 打赏
  • 举报
回复
刚才好像见过一个差不多的帖子.看看FomMain的FormClosed事件.
zhangyu_xl 2008-11-19
  • 打赏
  • 举报
回复
帮你顶了
yilanwuyu123 2008-11-19
  • 打赏
  • 举报
回复
mark
长沙三毛 2008-11-19
  • 打赏
  • 举报
回复
是否还有其他线程没有结束?
feiyun0112 2008-11-19
  • 打赏
  • 举报
回复
application.exit()

*****************************************************************************
欢迎使用CSDN论坛专用阅读器 : CSDN Reader(附全部源代码)
http://feiyun0112.cnblogs.com/

110,502

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧