如何从其他程序消息中通知当前程序
我正在使用“backgroundworker”等待来自其他程序的信号输入。我发现这会降低我的系统性能。有没有任何编程技术可以帮助我等待来自其他程序或exe的信号?所以我不需要创建一个线程来等待一直有信号。我需要类似委托事件之类的东西,其中有时会来自其他程序。然后我的函数将相应地触发。 或者有什么技术可以等待来自其他exe的消息或信号?
I am using "backgroundworker" to wait a signal input from other program. i found that will be slow down my system performance. Is there any Programming technique can help me to wait a signal from other program or exe? So i no need make a thread to wait there is a signal all the time. I need a something like delegate events where there is sometime out coming from other program.. then my function will trigger by accordingly.
or is any technique to wait a message or signal from other exe?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以使用命名互斥体进行跨进程同步。以下链接可帮助您了解互斥体和同步技术:
http://msdn.microsoft.com/en-us/library/system.threading.mutex(v=VS.100).aspx
http://www.albahari.com/threading/part2.aspx
想要:不受 AbandonedMutexException 影响的跨进程同步
You can use named Mutexes for cross process synchronization. Below links should help you understand Mutexes and synchronization techniques:
http://msdn.microsoft.com/en-us/library/system.threading.mutex(v=VS.100).aspx
http://www.albahari.com/threading/part2.aspx
Wanted: Cross-process synch that doesn't suffer from AbandonedMutexException
如果您需要针对此跨程序甚至远程通信的强大解决方案,请考虑使用 ActiveMQ 或 Microsoft MSMQ(非 JMS)等 JMS 服务器。我个人更喜欢ActiveMQ。
ActiveMQ 具有用于发布和订阅主题和队列的适配器。您可以使用 http://activemq.apache.org/nms/ 通过 C# 进行连接。
If you need a robust solution for this cross program or even remote communication consider using a JMS server like ActiveMQ or Microsoft MSMQ (non-JMS). I personally prefer ActiveMQ.
ActiveMQ has adapters for publish and subscribe for topics and queues. You can use http://activemq.apache.org/nms/ for connecting thru C#.
您正在寻找的是命名管道。
http://msdn.microsoft.com/en-us/library/bb546085.aspx
What you're looking for is named pipes.
http://msdn.microsoft.com/en-us/library/bb546085.aspx