title: C# UDP Communication-Stack implementation advise
body: <p>I am currently writing a C# Program and am struggling a bit with a conceptional question.</p>
  
  <p>A domain of the application is the communication with a Microcontroller via UDP. Therefore I am using the UDPClient and wrote a 'communicator' which does some encoding/decoding, checksum checks, etc.</p>
  
  <p>I need to have some kind of Controller which allows me to send commands to the UDP-Server (the device). Some of them are a single pair of Send/Receive, others are long-running.</p>
  
  <p>I thought about the following implemenation:
  <a href="https://i.stack.imgur.com/1tq43.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1tq43.png" alt="enter image description here"></a></p>
  
  <p>My idea was that every capability of my Microcontroller/UDP-Server is abstracted in a class, which has an 'Execute'-function which subscribes to the 'Receive' of the underlying Communicator and sends it request.</p>
  
  <p>However, I am a bit stuck here: I could wait in the 'Execute ' function of each task(capability) for an event which I trigger in the OnReceive-Handler (or timeout). But that would not work if I one task needs multiple Send/Receive.</p>
  
  <p>So, is there any good Design-Pattern for that? Or does anyone have a good advise on how to implement it in a proper way?</p>