如何在C#中传递应用程序的单例/单个实例的参数?

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

我是C#的新手。以下是我的问题。 我创建了一个运行并驻留在系统托盘中的应用程序。当用户点击链接时,它会使用参数调用应用程序.. [exp:] c:\ ... \ TrayApp.exe%1。 问题是我们点击的次数是多少次,我们创建了n个实例。要求是第一次点击它应该创建实例,后来点击应该使用相同的实例,即使我们调用.exe 这是否可以在c#中实现。? 请帮忙。 我尝试过的事情: 我在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#中传递应用程序的单例/单个实例的参数?

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

发布评论

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

>www.elefans.com

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