如何检查是否有其他正在运行的应用程序实例 [英] How to check if there are other application instances running

查看:318
本文介绍了如何检查是否有其他正在运行的应用程序实例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经用C#编写的应用程序,这是摆在我们的服务器上。
当有人需要使用它,该应用程序直接从服务器开始,在我们的局域网的任何连接的PC。

I've written an application in C#, which is placed on our server. When someone needs to use it, the application is started directly from the server, from any connected PC in our LAN.

有没有简单的方法,以检查有多少实例正在运行?或者说,如果有任何其他实例一个比由我启动

Is there any easy way, to check how many instances are running ? Or rather, if there is any other instance than the one started by me ?

编辑:

这是没有提供后一式两份,因为我不希望确保,有运行(如不同时运行多个应用程序1只有一个实例时间),但只检查,如果除了我之外有人运行它(在正常情况下,它具有在同一时间多台PC上工作)

this is not a duplicate of provided post, because I don't want to make sure, that there is only one instance running (as in "don't run more than 1 app at the same time") but to just check, if someone other than me is running it (in normal situations it has to work at the same time on more than one PC)

推荐答案

有没有简单的方法来知道一个程序的实例运行在同一个二进制文件的一些机器上 - 你需要计划在哪里比它可以以某种方式报道我跑到一些共享位置检查是否有其他正在运行的实例。

There is no easy way to know that instance of a program runs on some machine from the same binaries - you program need to somehow report "I'm running" to some shared location where than it can check if there are other instances running.

如果你只需要检查单个实例它可能会打开从同一位置的文件,它会失败,如果多个对于共享位置情况下,尝试打开它。

If you only need to check for single instance it may be possible to open a file from the same location and it will fail if multiple instances try to open it.

夫妻选项来计算实例:


  • 与计算机的名称更新一些文件

  • 某些Web服务/网站来ping

  • 共享DB

请注意,这也意味着,如果程序死亡有可能无法在大约完成此特定实例共享位置报告

Note that it also means if program dies there may not be report in the shared location about this particular instance finished.

这篇关于如何检查是否有其他正在运行的应用程序实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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