0

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!

Tyler
  • 416
  • 4
  • 11

1 Answers1

0

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.

PavlinII
  • 1,061
  • 1
  • 7
  • 12
  • Yeah i know about UDP, for this reason i used it instead of TPC. I just need an exchange of messages, isnt a problem if some message is lost, the important is that if i have 50 child exe, the main app should handle 50 incoming messages every second, without freeze itself and any other child. About WCF, as you said, is a too robust solution, like an SQL server. There will be too much configuration to do for just 1 short string per exe. I dont want to mess up the registry for this, better avoid. And about the local file, that will be good for 2 exe (1 write and 1 read) not for 51 IO op./s – Tyler Oct 17 '19 at 10:03
  • I will try sendmessage/postmessage today. Not used untill now becase im afraid of the stability. My question is: are these Windows functions stable enough for 50 exe in "send mode" (every second) and 1 exe in "read mode" (every second)? – Tyler Oct 17 '19 at 10:08
  • Sending messages is what Windows is based on. Make an empy WinForms, override WndProc and log messages into some file (not to UI!) to see how many messages are send just when you move your mouse over the form. My idea of file storege was based on 50 files. One file for one EXE, therefore ONE exe is writing and ONE exe is reading/deleting. Using registry is also quite lightweight solution. – PavlinII Oct 31 '19 at 09:25
  • I end up with TCP, cause UDP dosent order the messages. Sendmessage/postmessage was not good because i got stucked in "wait for message" function. Freezing the form and/or other functions by waiting messages. WndProc can be good, but i have alreadyother function that override this. And can delay the messages elaboration. So... TCP in localhost. I need to open the connection and wait for useless response everytime, but cant do anything else. Thank you! – Tyler Oct 31 '19 at 15:19