C#中:如何

编程入门 行业动态 更新时间:2024-10-22 23:01:34
本文介绍了C#中:如何 - 接受新的参数,单实例应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我创建使用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#中:如何

本文发布于:2023-11-16 14:27:49,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1605112.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!