I am writing an network application. I create many threads to go off and do stuff. I need them to store data in a datatable that is bound to a datagridview.
I am worried about being threadsafe.
I've done a lot of googling for ideas and examples. What I have come up with is the Producer-Consumer model with a threadsafe queue.
Each Producer thread will store data into a threadsafe queue.
A single consumer thread will pick records out of the queue (when available) and put them into the datatable that is bound to the datagridview.
I in am a bit over my head here. I am finding threading tough enough to learn (and just scraping by)
I've seen examples that are very different to each other, often over complicated and I am finding it tough to understand them and work out which way to do things. Some are dependent upon .net features that are in newer versions of .net than I am targeting.
Could someone please help me with a sample (with explanation) of how to do this.
I have some ideas about how to write the producer (they could be wrong), but I don't know where to start with the consumer.
There will be many producers, but a single consumer. I am targeting .net 4.0 and using visual studio 2010 so that I can still work with some Windows XP machines.
(yes I know that the XP machines should be retired, but they are separated from the internet and locked down a lot)
Thanks in advance