我的应用程序不会以编程方式关闭 [英] My app won't close programatically

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

问题描述

首先运行:

[STAThread]

static void Main()

{

// ///////////////////

///不要让app运行多个实例。

///

处理aProcess = Process.GetCurrentProcess();

string aProcName = aProcess.ProcessName;

if(Process.GetProcessesByName(aProcName) ).Length> 1)返回;


Application.Run(new frmMain());

}

然后这个运行:

public frmMain()

{

InitializeComponent();

ProcessFaxes();

关闭();

}


即使在运行关闭功能后,程序仍保持打开状态。我不能

弄清楚如何使我的程序关闭。我已经尝试了Application.Exit()

但仍然没有快乐。


如果我单击退出按钮,我将表单关闭:


私有空btnExit_Click(对象发件人,System.EventArgs e)

{关闭();}


请帮助!


谢谢。


-

- = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = -
http://www.vbmark.com

获取免费软件,学习东西,制作钱。

- = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = -

First this runs:
[STAThread]
static void Main()
{
/////////////////////
/// Don''t let app run more than one instance.
///
Process aProcess = Process.GetCurrentProcess();
string aProcName = aProcess.ProcessName;
if (Process.GetProcessesByName(aProcName).Length > 1) return;

Application.Run(new frmMain());
}
Then this runs:
public frmMain()
{
InitializeComponent();
ProcessFaxes();
Close();
}

Even after running the Close function the program stays open. I can not
figure out how to make my program close. I''ve tried Application.Exit()
but still no joy.

If I click the Exit button that I made the form closes fine:

Private void btnExit_Click(object sender, System.EventArgs e)
{Close();}

Please help!

Thank you.

--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
http://www.vbmark.com
Get freeware, learn things, make money.
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

推荐答案

尝试Application.Exit()


Brendan


" vbMark"写道:
Try Application.Exit()

Brendan

"vbMark" wrote:
首先运行:

[STAThread]
static void Main()
/// /// //////////////////
///不要让app运行多个实例。
///
处理aProcess = Process.GetCurrentProcess();
字符串aProcName = aProcess.ProcessName;
if(Process.GetProcessesByName(aProcName).Length> 1)返回;

Application.Run(新的frmMain());
}

然后运行:

public frmMain()
{
InitializeComponent();
ProcessFaxes();
关闭();
}
即使在运行Close函数后,程序仍保持打开状态。我无法弄清楚如何让我的程序关闭。我已经尝试了Application.Exit()
但仍然没有快乐。

如果我单击退出按钮,我就可以将表单关闭:

私有void btnExit_Click(object sender,System.EventArgs e)
{Close();}

请帮忙!

谢谢。
-
- = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = -
http://www.vbmark.com
获得免费软件,学习东西,赚钱。
- = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = -
First this runs:
[STAThread]
static void Main()
{
/////////////////////
/// Don''t let app run more than one instance.
///
Process aProcess = Process.GetCurrentProcess();
string aProcName = aProcess.ProcessName;
if (Process.GetProcessesByName(aProcName).Length > 1) return;

Application.Run(new frmMain());
}
Then this runs:
public frmMain()
{
InitializeComponent();
ProcessFaxes();
Close();
}

Even after running the Close function the program stays open. I can not
figure out how to make my program close. I''ve tried Application.Exit()
but still no joy.

If I click the Exit button that I made the form closes fine:

Private void btnExit_Click(object sender, System.EventArgs e)
{Close();}

Please help!

Thank you.

--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
http://www.vbmark.com
Get freeware, learn things, make money.
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-



我道歉,我没有在回复之前完全阅读你的帖子。


你说你没有成功使用Application.Exit(),你在哪里?b $ b把它放?在Close()内?另外,你有任何线程运行其

IsBackground属性不是真的吗?


Brendan

" vbMark"写道:
I apologize, I didna??t fully read your post before replying.

You said that you havena??t had success with Application.Exit(), where did you
put it? Within Close() ? Also, do you have any threads running whose
IsBackground property is not true?

Brendan
"vbMark" wrote:
首先运行:

[STAThread]
static void Main()
/// /// //////////////////
///不要让app运行多个实例。
///
处理aProcess = Process.GetCurrentProcess();
字符串aProcName = aProcess.ProcessName;
if(Process.GetProcessesByName(aProcName).Length> 1)返回;

Application.Run(新的frmMain());
}

然后运行:

public frmMain()
{
InitializeComponent();
ProcessFaxes();
关闭();
}
即使在运行Close函数后,程序仍保持打开状态。我无法弄清楚如何让我的程序关闭。我已经尝试了Application.Exit()
但仍然没有快乐。

如果我单击退出按钮,我就可以将表单关闭:

私有void btnExit_Click(object sender,System.EventArgs e)
{Close();}

请帮忙!

谢谢。
-
- = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = -
http://www.vbmark.com
获得免费软件,学习东西,赚钱。
- = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = -
First this runs:
[STAThread]
static void Main()
{
/////////////////////
/// Don''t let app run more than one instance.
///
Process aProcess = Process.GetCurrentProcess();
string aProcName = aProcess.ProcessName;
if (Process.GetProcessesByName(aProcName).Length > 1) return;

Application.Run(new frmMain());
}
Then this runs:
public frmMain()
{
InitializeComponent();
ProcessFaxes();
Close();
}

Even after running the Close function the program stays open. I can not
figure out how to make my program close. I''ve tried Application.Exit()
but still no joy.

If I click the Exit button that I made the form closes fine:

Private void btnExit_Click(object sender, System.EventArgs e)
{Close();}

Please help!

Thank you.

--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
http://www.vbmark.com
Get freeware, learn things, make money.
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-



" =?Utf-8? ?乙QnJlbmRhbiBHcmFudA == = QUOT; < GR **** @ NOSPAMdahat.com>写在

新闻:3E ********************************** @ microsof t .com:
"=?Utf-8?B?QnJlbmRhbiBHcmFudA==?=" <gr****@NOSPAMdahat.com> wrote in
news:3E**********************************@microsof t.com:
Application.Exit()
Application.Exit()




试一试,但它仍然是一样的。它可以追溯到Static Void Main

,但表格保持打开状态。


-

- = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = -
http://www.vbmark.com

获取免费软件,学习东西,赚钱。

- = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = -



Gave it a try but it''s still the same. It goes back to Static Void Main
but the form stays open.

--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
http://www.vbmark.com
Get freeware, learn things, make money.
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-


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

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