samedi 26 mars 2016

How to communicate data from children workers to parent class?

I'm writing an application in C# that needs to spawn worker threads that will retrieve data from various places (databases, ftp sites, websites, text files, queues etc. etc.) and make the data available to another consuming thread.

I have the application written and it's working nicely.

However, I want to restructure it so that it's more testable and to attempt to follow SRP. Right now, almost all of the work is done in one class.

Currently, my main class is loading configuration files (one for each type of data retriever - database, web, text file, ftp etc.) and starting a timer per type to check for work. If there is work to do, the background thread does the work and populates a ConcurrentQueue which is then read by the main thread.

What's the best way to restructure to code to meet my needs? How do I best communicate the data and performance metrics back from the workers? What are the best design patterns to use in this scenario?

Aucun commentaire:

Enregistrer un commentaire