当进程可以来来去去时,如何在 C# 中进行进程间通信?

发布于 2024-12-23 16:05:56 字数 197 浏览 2 评论 0原文

我有 2 个进程 WriterProc 和 ReaderProc。

WriterProc 仅写入,ReaderProc 仅读取。我可以使用命名管道进行通信,但问题是 ReaderProc 在 writer 编写时可能不存在,反之亦然。

两者可以同时处于活动状态,因此可能需要写入和读取之间的同步。

c# 4 中建议的方式是什么?

I have 2 process WriterProc and ReaderProc.

WriterProc only writes and ReaderProc only reads. I can use named pipes for communication but the problem is ReaderProc may not be alive when writer is writing it or vice-versa.

Both can be active at the same time so synchronization between writes and reads may be required.

What would be suggested way in c# 4?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

晨曦慕雪 2024-12-30 16:05:56

消息队列服务专为在像您这样的情况下使用而设计。它们提供有保证的消息传递,因此如果写入器在读取器未运行时忙于写入,则读取器在启动后会发现一个充满消息的队列。

Message Queuing services are designed for use in situations like yours. They provide guaranteed message delivery, so if the writer was busy writing while the reader was not running, the reader would find a queue full of messages after starting up.

无可置疑 2024-12-30 16:05:56

让它们成为 WCF 怎么样?

写入器 WCF 将在即将读取时向读取器 WCF 发出停止读取信号,然后在写入完成后发出信号。

How about making them WCFs.

The writer WCF will signal Reader WCF to stop reading when it is about to read and then signal once writing is done.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文