[英]Best way to let multiple .NET apps communicate with each other
So, first of all sorry for my bad english.所以,首先对不起我的英语不好。 Back to the questio, i have a main app, with a tab control, each tab contain another .NET exe.回到问题,我有一个主应用程序,带有一个选项卡控件,每个选项卡都包含另一个 .NET exe。 These need to send infos to the main app.这些需要将信息发送到主应用程序。 Example: Each exe in a tab have a random generated guid every second and the main app need to catch this and show in a listview or something as long the exe is "alive".示例:选项卡中的每个 exe每秒都有一个随机生成的 guid,主应用程序需要捕获它并在列表视图中显示或只要 exe 是“活动的”。
Currently i'm using SQLite, and everytime a new exe is started this one write in a table.目前我正在使用 SQLite,每次启动一个新的 exe 时,都会在表格中写入。 Before closing it this exe remove the recod from the table.在关闭它之前,这个 exe 从表中删除记录。 In the mainwhile, the main app retrieve this update table and show the "alive" exe and the random generated guid (every second).在主应用程序中,主应用程序检索此更新表并显示“活动”exe 和随机生成的 guid(每秒)。 All works fine, the problem is that i need to abandon this method and remove the two dll of SQLite.一切正常,问题是我需要放弃这种方法并删除 SQLite 的两个 dll。
What i tried is:我尝试的是:
So, there is a way for that?那么,有没有办法呢? In local.在当地。 Like, i don't know.. user32 sendmessage maybe?就像,我不知道.. user32 sendmessage 也许? Or this method is too invasive for just a short string?或者这种方法对于短字符串来说太具有侵入性了? Considering that the N sub exe are process "inside" the main one, there is not a way to obtain infos from child process?考虑到 N 个子 exe 是主进程“内部”的进程,没有办法从子进程获取信息吗?
Thanks for your help!谢谢你的帮助!
UDP does not guarantee delivery of the packet by-desing. UDP 不保证按设计交付数据包。 Unless you implement your own confirmation protocol above it.除非你在它上面实现你自己的确认协议。 But implementation itself should be stable.但是实现本身应该是稳定的。
Using TCP will provide similar results.使用 TCP 将提供类似的结果。 You'll just have to deal with reconnect stuff.你只需要处理重新连接的东西。
SendMessage/PostMessage is the easiest and straight forward method. SendMessage/PostMessage 是最简单直接的方法。 But it will not allow you to pass string directly.但它不允许你直接传递字符串。 Take a look at RegisterWindowMessage to register your own message and SendMessage with HWND_BROADCAST handle.查看 RegisterWindowMessage 以注册您自己的消息并使用 HWND_BROADCAST 句柄注册 SendMessage。 And you'll have to send pointer to your string.而且您必须将指针发送到您的字符串。 Since SendMessage is synchronous you should be teoreticaly fine with disposing of that message, but I haven't tried that.由于 SendMessage 是同步的,因此您应该可以很好地处理该消息,但我还没有尝试过。 Another option would be storing string somewhere-else (registry, file) and sending just update notification using SendMessage.另一种选择是将字符串存储在其他地方(注册表、文件)并使用 SendMessage 发送更新通知。 And the main app will read and delete that registry/file record.主应用程序将读取并删除该注册表/文件记录。
Self hosted WCF with netNamedPipeBinding should work as well.带有 netNamedPipeBinding 的自托管 WCF 也应该可以工作。 But that would be propably too robust solution.但这可能是过于强大的解决方案。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.