在c#中从第二个实例向第一个实例添加项 [英] Add Item to first Instance from second Instance in c#

查看:87
本文介绍了在c#中从第二个实例向第一个实例添加项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的所有人!



我有一个带有列表框的Windows表单应用程序。此列表框中的第一项是参数(例如:application.exe c:\test.pdf)。现在我想添加更多项目,当我用Argument打开我的应用程序的下一个实例时。如果项目已添加到列表框中,则第二个实例必须为关闭。你能发帖,我怎样才能在c#中实现它?任何人都可以帮助解决一个片段吗?



非常感谢!



Greetz

HHubi2

Dear All!

I have a Windows form application with a listbox. The first item in this listbox comes in an Argument (Example: "application.exe c:\test.pdf"). Now i would like to add further items, when i open up next instance of my application with Argument. And the second instance have to be Close, if the item was added to the listbox. Can you post, how i can realize it in c#? Can anybody help with a snippet?

Thanks so much!

Greetz
HHubi2

推荐答案

请参阅我过去关于流程实例与单个实例检测之间通信的答案:

仅向一个流程实例输入多个命令 [ ^ ],

自定义Windows右键单击命令启动多个实例 [ ^ ]。



作为发送文件名的最合适的机制s到第一个实例只是命令行,另请参阅我关于此主题的文章:枚举基于命令行实用程序 [ ^ ]。



我的实用程序是最容易使用的,但我也建议在文章中使用更复杂和更全面的实用程序。



-SA
Please see my past answer on communications between process instances and detection of single instance:
Enter multiple commands to only one process instance[^],
Custom Windows right-click command launching multiple instances[^].

As the most adequate mechanism for sending the file names to the first instance is just the command line, see also my article on this topic: Enumeration-based Command Line Utility[^].

My utility is the easiest to use, but I also recommend more complex and comprehensive one in the article.

—SA


这篇关于在c#中从第二个实例向第一个实例添加项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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