如何在C#中传递应用程序的单例/单个实例的参数? [英] How do I pass arguments for singleton/ single instance of an application in C#?

查看:355
本文介绍了如何在C#中传递应用程序的单例/单个实例的参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是C#的新手。以下是我的问题。



我创建了一个运行并驻留在系统托盘中的应用程序。当用户点击链接时,它会使用参数调用应用程序..

[exp:] c:\ ... \ TrayApp.exe%1。



问题是我们点击的次数是多少次,我们创建了n个实例。要求是第一次点击它应该创建实例,后来点击应该使用相同的实例,即使我们调用.exe



这是否可以在c#中实现。?< br $>


请帮忙。



我尝试过的事情:



我在CodeProject中尝试过互斥锁和其他示例,但它们都限制创建实例但不调用现有实例中的方法。



我们可以使用Process获取实例吗?不确定。

I'm pretty novice to C#. Below is my problem.

I have created an application that runs and resides in systray. When user clicks a link it invokes the application with parameters..
[exp:] c:\...\TrayApp.exe %1.

The problem is the n number of times we click, we have n instances created. Requirement is on the first click it should create the instance, later clicks should use the same instance even though we call the .exe

Is this achievable in c#.?

Kindly help.

What I have tried:

I've tried mutex and other examples in CodeProject, but they all restrict creating instances but do not call a method in the existing instance.

Can we get the instance using Process ? Not sure.

推荐答案

Codeproject上有一两篇关于它的文章!

C#中的单实例应用程序 [ ^ ]

WPF单实例应用程序 [ ^ ]

具有从系统托盘还原能力的C#单实例应用程序(使用互斥锁) [ ^ ]

单一实例应用程序 [ ^ ]
There is an article or two about that here on Codeproject!
Single Instance Application in C#[^]
WPF Single Instance Application[^]
C# Single Instance App With the Ability To Restore From System Tray (Using Mutex)[^]
Single Instance Application[^]


这篇关于如何在C#中传递应用程序的单例/单个实例的参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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