Synchronization between two processes in C#.?

僤鯓⒐⒋嵵緔 提交于 2019-12-04 06:19:49

问题


Is there any way so that we can synchronize two independent processes? Like if they are sharing a resource, I would like to sync them.

I am using C#.


回答1:


you can use the Mutex class

see documentation here : http://msdn.microsoft.com/en-us/library/system.threading.mutex.aspx




回答2:


You can use WCF with pipe binding, or named synchronization objects, Mutex for example for synchronization between two processes




回答3:


Mutexes will give you cross process sync.

You could also implement an API in WCF using named pipes, which could give you a nice synchronisation in OO code without system calls and it fully unit testable. Named pipes would also give you not just sync but communication as well.



来源:https://stackoverflow.com/questions/1795143/synchronization-between-two-processes-in-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!