简体   繁体   中英

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. 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".

Currently i'm using SQLite, and everytime a new exe is started this one write in a table. Before closing it this exe remove the recod from the table. In the mainwhile, the main app retrieve this update table and show the "alive" exe and the random generated guid (every second). All works fine, the problem is that i need to abandon this method and remove the two dll of SQLite.

What i tried is:

  • UDP socket between the N clients and the main app, but is not so stable. And sometime some exe got freezed. (using TCP will be so "heavy" for the only purpose to send a short string. Right?)
  • Changing the window text of the other exe and retrive it via processinfo, but is not updating it, i get it just the first time string.

So, there is a way for that? In local. Like, i don't know.. user32 sendmessage maybe? 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?

Thanks for your help!

UDP does not guarantee delivery of the packet by-desing. Unless you implement your own confirmation protocol above it. But implementation itself should be stable.

Using TCP will provide similar results. You'll just have to deal with reconnect stuff.

SendMessage/PostMessage is the easiest and straight forward method. 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. 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. Another option would be storing string somewhere-else (registry, file) and sending just update notification using SendMessage. And the main app will read and delete that registry/file record.

Self hosted WCF with netNamedPipeBinding should work as well. But that would be propably too robust solution.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM