Click here to Skip to main content
15,884,298 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm looking for guidance for the best methodology for the following scenario;

I want to send messages from multiple locations (classes) and threads within the main program.

I need a class or DLL that can receive these messages, act upon them, and return a result to the specific calling client. It's possible to have multiple connections at once.

Any hints as to which technology or methodology I could use to satisfy this requirement?

What I have tried:

I'm trying to avoid TCP sockets. Message Queuing looks promising except that it's old technology.
Posted
Updated 7-Apr-22 8:55am
Comments
0x01AA 7-Apr-22 17:05pm    
Mailslots?

I develop in C++, not C#, so I don't know if there's any C#-specific thing that you could use.

So what if message queueing is "old"? Queueing messages on threads is a common approach within an .exe.

You could also use UDP if your messages aren't too long (~1500 bytes), but this will have more overhead. If the destination is in the same .exe, I provide a way to bypass the IP stack and just deliver the message directly.

If the clients aren't threads, but classes, the entity that receives a result must be able to forward it to the correct client. This means putting some kind of identifier in the request and echoing it in the result.

Another option is work queues. The server would take requests off its work queue and return results to the client work queue. One thread on each side, with the one on the client side forwarding the response to the correct client. If either side can block when processing a request or reply, consider having a thread pool for that side.
 
Share this answer
 
You may want to look at EventAggregator[^]. It's a publish/subscribe framework that I use in a WPF application I'm developing but it may be available in other frameworks also.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900