Threadsafe async code design
With a single UDP/TCP client or serial connection, I want to send and receive concurrently. The sending and receiving code is asynchronous so locks are out of the question. Trying to follow closely with a hosted app and dependency injection. Been stuck thinking about it for a few hours because every solution I've been able to come up has a gotcha.
Attached is the logic
Thought splitting into two classes would be good but if I'm working with the same UDP/TCP/serial connection then it goes back to the locking issue. Adding a third class for message queueing could work but then you might end up waiting for bytes with outgoing messages in queue that could've been sent by the time you receive the next bytes.
Attached is the logic
Thought splitting into two classes would be good but if I'm working with the same UDP/TCP/serial connection then it goes back to the locking issue. Adding a third class for message queueing could work but then you might end up waiting for bytes with outgoing messages in queue that could've been sent by the time you receive the next bytes.
GroundCompanion.cs2.16KB