我创建使用NZB文件下载二进制文件(C#)程序,有可能只是在任何时候运行我的应用程序的一个实例。
I'm creating a (C#) program that downloads binaries using NZB files, there may only be one instance of my application running at any time.
因此,当用户doubleclicks一个.nzb文件和我的程序不运行,它应该启动并处理它(容易的,档案登记)。现在,如果我的程序正在运行,我不想发动第二个实例 - 我要与已经运行的实例拿起指定的文件
So when a user doubleclicks an .nzb-file and my program is not running, it should start and process it (easy, file registration). Now if my program is already running, I do NOT want to launch a second instance - I want the already-running instance to pick up the specified file.
使我的应用程序单实例可以使用Visual Basic DLL与.IsSingleInstance把戏做,但我不想去那里。
Making my app single-instance can be done using the Visual Basic DLL with the .IsSingleInstance trick, but I don't want to go there.
正确的方法似乎是使用一个互斥体,以确保我的应用程序是单实例,但现在我卡上如何规定的参数(.nzb文件)传递给已经运行的实例。
The right way seems to be to use a mutex to ensure my app is single-instance, but now I'm stuck on how to pass the specified parameter (the .nzb file) to the already-running instance.
帮助将AP preciated! : - )
Help would be appreciated ! :-)
推荐答案下面是一个nice没有IsSingleInstance实现使用互斥,但处理的参数。和here是一家具有万一你改变主意IsSingleInstance 。 :)
Here is a nice implementation without IsSingleInstance that uses a Mutex but handles arguments. And here is one with IsSingleInstance in case you change your mind. :)
更多推荐
C#中:如何
发布评论