在C#中的跨进程锁定 [英] Cross-Process Locking in C#

查看:1011
本文介绍了在C#中的跨进程锁定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经写了,将在(1)一个窗口服务,(2)Web应用程序,以及(3)Windows窗体应用程序同一个盒子中使用的API。他们都需要共享一个非常小的一组常见的数据(几整数,日期和字符串,我可以把作为一个单一类的属性)。

I've written an API that will be used on the same box in (1) a windows service, (2) a web application, and (3) a windows forms application. They all need to share a very small set of common data (a few ints, a date, and a string that I could put as properties of a single class).

什么样的​​锁定机制我可以使用跨进程,使这三个进程可以安全地共享资源,并碰上冲突?的

What sort of locking mechanism can I use cross-process so that the three processes can share the resources safely and run into conflicts?

编辑:没有数据库请,找不要求额外的依赖... preferably溶液将使用的共享存储器中的溶液,或以某种方式在文件系统

no databases please, looking for a solution that doesn't require additional dependencies... preferably the solution would use shared memory, or the file system in some way.

推荐答案

有关在C#/。NET跨进程锁,你可以使用的named系统互斥

For cross-process locking in C#/.Net, you can use a named system Mutex.

这篇关于在C#中的跨进程锁定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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