如何确保有一个应用程序实例正在运行

如何确保有一个应用程序实例正在运行

问题描述:

我想检查用户何时双击应用程序图标,确认该应用程序的其他实例尚未在运行.

I want to check when the user double click on applictaion icon that no another instance of this application is already running.

我了解了My.Application,但我仍然不知道该怎么办.

I read about My.Application but i still don't know what to do.

最常见的模式是使用Singleton模式.由于您还没有表示语言,所以我假设您在这里指的是C#-如果不是,则大多数OO语言的原理仍然相同.

The most common pattern for doing this is to use the Singleton pattern. As you haven't indicated a language, I'm going to assume that you are referring to C# here - if not, the principles are still the same in most OO languages.

这篇文章应为您提供一些帮助.

This article should give you some help.