Hi, I would like to know if there is something similar to the await statement that is used with tasks that I can implement using threads in C #?
What I want to do:
Run Thread A, calculate some data and put the result on the variable x . After that, the variable x transferred to another thread B and at the same time, Thread A starts to calculate some data again, and thread B starts another calculation with the result x .
UPDATE: Well, there seems to be some confusion, so I will be more precise in my description:
I use two sensors that produce data. The data must be retrieved so that SensorA data is retrieved (which takes a lot of time), and immediately after that, the data from SensorB must be received in a different stream, while SensorA continues to retrieve another data block. The problem is that I cannot set the data of both sensors in one queue, but I need to save the data of both sensors in ONE data structure / object.
My idea was this:
- Receive data from sensor A in stream A.
- Give the result of Thread B and restart Thread A.
- While Thread A starts again. Thread B receives data from sensor B and calculates data from sensors A and B
It can be assumed that Thread A always requires a longer time than Thread B
source share