应用已经在运行吗? [英] Is app already running?

查看:79
本文介绍了应用已经在运行吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在VB.NET中,如何查看

应用程序的实例是否已在运行?

In VB.NET, how do you check to see if an instance of your
application is already running?

推荐答案

*" Michael" <一个******* @ discussions.microsoft.com> scripsit:
* "Michael" <an*******@discussions.microsoft.com> scripsit:
在VB.NET中,如何查看
应用程序的实例是否已经在运行?
In VB.NET, how do you check to see if an instance of your
application is already running?




< http://www.google.com/groups?selm = blgrft%24c51nq%244%40ID-208219.news.uni-berlin.de>


-

Herfried K. Wagner

MVP·VB Classic,VB.NET

< http://www.mvps.org/dotnet>



<http://www.google.com/groups?selm=blgrft%24c51nq%244%40ID-208219.news.uni-berlin.de>

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>


在文章< bn ************ @ ID-208219.news.uni-berlin.de> ;,Herfried K. Wagner [ MVP]写道:
In article <bn************@ID-208219.news.uni-berlin.de>, Herfried K. Wagner [MVP] wrote:
*" Michael" <一个******* @ discussions.microsoft.com> scripsit:
* "Michael" <an*******@discussions.microsoft.com> scripsit:
在VB.NET中,如何查看
应用程序的实例是否已经在运行?
In VB.NET, how do you check to see if an instance of your
application is already running?



< http ://www.google.com/groups?selm = blgrft%24c51nq%244%40ID-208219.news.uni-berlin.de>



<http://www.google.com/groups?selm=blgrft%24c51nq%244%40ID-208219.news.uni-berlin.de>




这是一个如果你需要获得一些关于前一个过程的信息,那么这样做是很好的方法 - 特别是如果你要传递信息

。但是,如果你有简单的需求,就像你关心的那样,如果它运行 - 这是另一种方法。


Imports System.Threading


....


Sub Main()

Dim拥有为布尔值

Dim mut As New Mutex(True,myuniquemutexname,拥有)


如果拥有那么

Application.Run(New MainForm())

mut.ReleaseMutex()

Else

MessageBox.Show(之前的实例已在运行)

结束如果


End Sub


无论如何,它是我经常使用的另一种选择:)


-

Tom Shelton

MVP [Visual Basic]



That is a good way to do it if you need to get a bit of information
about the previous proces - especially if your going to pass information
to it. But if you have simple needs, like all you care about is if it
is running - here is an alternate method.

Imports System.Threading

....

Sub Main()
Dim owned As Boolean
Dim mut As New Mutex(True, "myuniquemutexname", owned)

If owned Then
Application.Run(New MainForm())
mut.ReleaseMutex()
Else
MessageBox.Show("A previous instance is already running")
End If

End Sub

Anyway, it is an alternative that I use a lot :)

--
Tom Shelton
MVP [Visual Basic]


* Tom Shelton< to * @ mtogden.com> scripsit:
* Tom Shelton <to*@mtogden.com> scripsit:
< http://www.google.com/groups?selm = blgrft%24c51nq%244%40ID-208219.news.uni-berlin。 de>
这是一个很好的方法,如果你需要获得关于前一个过程的一些信息 - 特别是如果你要传递信息
。但是如果你有简单的需求,就像你关心的那样,如果它正在运行 - 这是另一种方法。
<http://www.google.com/groups?selm=blgrft%24c51nq%244%40ID-208219.news.uni-berlin.de>
That is a good way to do it if you need to get a bit of information
about the previous proces - especially if your going to pass information
to it. But if you have simple needs, like all you care about is if it
is running - here is an alternate method.



[...] Dim mut As New Mutex (正确,myuniquemutexname,拥有)


[...] Dim mut As New Mutex(True, "myuniquemutexname", owned)




我记得我发布了这样一个样本的链接。


;-)


-

Herfried K. Wagner

MVP·VB Classic,VB.NET

< http://www.mvps.org/dotnet>



I remember I posted a link to a sample like this.

;-)

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>


这篇关于应用已经在运行吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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