两个应用程序的进程同步 [英] Process synchronization from two application

查看:228
本文介绍了两个应用程序的进程同步的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



让我说我有应用程序并且两个都使用一个公共资源让我们说一个文本文件,我怎么能同步这两个应用程序的异常。



问候,

Tasu

Hi Guys,

Lets say i have application and both are using one common resource lets say a text file,how can i synchronize these two application for exception.

Regards,
Tasu

推荐答案

你可以用一个名字 mutex http://en.wikipedia.org/wiki/Mutual_exclusion [ ^ ]。



由于所有进程都是隔离的并且在它们各自的内存空间中运行,因此需要一些共享同步对象。通过给一些对象提供相同的名称来实现这种共享。请参阅: http://msdn.microsoft.com/en-us/library/system .threading.mutex.aspx [ ^ ]。



使用构造函数使用互斥锁名称;它将允许它们充当两个进程共享的IPC设备。

另请参阅: http: //en.wikipedia.org/wiki/Inter-process_communication [ ^ ]。



-SA
You can use a named mutex: http://en.wikipedia.org/wiki/Mutual_exclusion[^].

As all processes are isolated and run in their separate memory spaces, you need some shared synchronization object. Such sharing is achieved through giving some objects identical names. Please see: http://msdn.microsoft.com/en-us/library/system.threading.mutex.aspx[^].

Use the constructors using the mutex name; it will allow them to act as an IPC device shared by both processes.
See also: http://en.wikipedia.org/wiki/Inter-process_communication[^].

—SA


这篇关于两个应用程序的进程同步的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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