如何返回到一个已经打开的应用程序,当用户试图打开,如果同一版本的新实例? [英] How to Return to an already open application when a user tries to open a new instance if same version?

查看:92
本文介绍了如何返回到一个已经打开的应用程序,当用户试图打开,如果同一版本的新实例?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想如果我的程序已经运行仅当它运行相同版本开拓现有的实例。我注意到,这个问题被问了只有名称存在,但如果该版本是旧的,我只是想通知的旧版本仍在运行,用户请开始此版本之前删除旧版本。

I want to open up an existing instance if my program is already running only if its running the same version. I noticed that this question was asked for only if the name exists, but what if the version is older, I just want to notify the user that an older version is still running, "please remove older version before starting this version."

另一个链接是这个:
返回一个已经打开的应用程序,当用户试图打开一个新的实例,但他们不谈论关闭一个例如,如果检测到一个较旧的或较新的版本。

The other link is this one: Return to an already open application when a user tries to open a new instance but they don't talk about closing an instance if an older or newer version is detected.

推荐答案

您可以用我描述的这里和描述这里使用的 System.Threading.Mutex

You can use a variant of the method which I describe here and that described here using System.Threading.Mutex.

我想你可以有两个互斥的。由GUID和版本号命名一个GUID和互斥乙命名互斥。

I guess you could have two mutex's. Mutex A named by a GUID and mutex B named by GUID and version number.

您新的实例可以先检查互斥上启动。如果互斥锁不存在,则没有其他版本正在运行。如果互斥体存在,那么的部分的其他版本正在运行。

Your new instance can first check for mutex A on start up. If mutex A does not exist, then no other version is running. If mutex A exists then some other version is running.

新的实例就可以检查互斥的B存在,用它自己的版本号。若B确实存在,那么其它实例是相同的版本的新的实例,如果B不存在,则一些其它版本正在运行

The new instance can then check for existence of mutex B, using it's own version number. If B does exist, then the other instance is the same version as the new instance, if B doesn't exist, then some other version is running.

这篇关于如何返回到一个已经打开的应用程序,当用户试图打开,如果同一版本的新实例?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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