I have C# multi threading program that using UART trough c++ COM object. I'm accessing UART from couple threads and it is not allowed.
My solutions:
What solution is the best and why? There is another solution?
I would suggest a dedicated thread that pulls requests from a ConcurrentQueue
and operates on the UART.
All other threads should Enqueue
requests and continue on with their work, so there's no waiting involved. Does that fit your needs?
Here's the documentation for ConcurrentQueue