I have an interesting exercise to solve from my professor. But I need a little bit of help so it does not become boring during the holidays.
The exercise is to
- create a multithreaded load balancer, that reads 1 measuring point from 5 sensors every second. (therefore 5 values every second).
- Then do some "complex" calculations with those values.
- Printing results of the calculations on the screen. (like max value or average value of sensor 1-5 and so on, of course multithreaded)
- As an additional task I also have to ensure that if in the future for example 500 sensors would be read every second the computer doesn't quit the job.(load balancing).
I have a csv textfile with ~400 measuring points from 5 imaginary sensors.
What I think I have to do:
- Read the measuring points into an array
- Ensure thread safe access to that array
- Spawn a new thread for every value that calculates some math stuff
- Set a max value for maximum concurrent working threads
I am new to multithreading applications in c# but I think using threadpool is the right way. I am currently working on a queue and maybe starting it inside a task so it wont block the application.
What would you recommend?