有没有高级、简单的 IPC 库

发布于 2024-12-24 19:56:35 字数 937 浏览 1 评论 0原文

是否有适用于 C# 的高级、简单的 IPC 库?似乎大多数帖子都指向使用 WCF。但这看起来比我需要的要复杂得多。我只想在两个 C# 应用程序之间发送异步消息,这两个应用程序可能位于也可能不在同一系统上。

我希望存在一些像下面这样简单易用的东西,它只需要一个 Send 和一个 OnRead 命令。 (链接是我希望存在的IPC库)。

private void StartServer()
{
    using (var link = new Link("InstanceName"))
    {
        link.OnRead += delegate(Link client, object data)
                           {
                               client.Send("Echoing " + data);
                           };
        link.Connect();
        Console.WriteLine("Press any key to stop the server.");
        Console.ReadKey();
    }
}

private void StartClient()
{
    using (var link = new Link("serverName", "InstanceName"))
    {
        link.OnRead += delegate(Link server, object data) { Console.WriteLine(data); };
        link.Connect();
        link.Send("Hello There!");
        Console.WriteLine("Press any key to stop the client.");
        Console.ReadKey();
    }
}

Are there any high level, simple IPC libraries for C#? It seems most posts point to using WCF. But this looks far more complicated than I need. I just want to send asynchronous messages between two C# apps that may or may not be on the same system.

I am hoping something exists that is as simple to use as the following which comes down to just a Send and an OnRead command. (Link is the IPC library I hope exists).

private void StartServer()
{
    using (var link = new Link("InstanceName"))
    {
        link.OnRead += delegate(Link client, object data)
                           {
                               client.Send("Echoing " + data);
                           };
        link.Connect();
        Console.WriteLine("Press any key to stop the server.");
        Console.ReadKey();
    }
}

private void StartClient()
{
    using (var link = new Link("serverName", "InstanceName"))
    {
        link.OnRead += delegate(Link server, object data) { Console.WriteLine(data); };
        link.Connect();
        link.Send("Hello There!");
        Console.WriteLine("Press any key to stop the client.");
        Console.ReadKey();
    }
}

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

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

发布评论

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

评论(2

谈场末日恋爱 2024-12-31 19:56:35

自托管 WCF 就很接近了。

Self-hosted WCF would come close.

海的爱人是光 2024-12-31 19:56:35

您可以查看我们的 MsgConnect,它完全满足您的需求,并且适用于包括 .NET 在内的许多平台。 MsgConnect 的设计灵感来自 Windows API - PostMessage/SendMessage/GetMessage 函数,但 MsgConnect 具有 Socket 传输功能,可让您通过网络发送消息。安装包中提供了示例。

You can take a look at our MsgConnect which offers exactly what you need and for many platforms including .NET. Design of MsgConnect is inspired by Windows API - PostMessage/SendMessage/GetMessage functions, yet MsgConnect has Socket transport which lets you send messages across network. Samples are available in the installation package.

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