Passing data / events between two worker threads in c#
I am currently writing a multi-threaded c# windows service . The software connects to one or more external sonic queues and waits for a message to be submitted.
Each queue is waitng for a message on a seperate thread. (As each thread pulls in slightly differerent, messages and the pre-processing is also slightly different
There is only one processing queue that takes the message from the queue and processes it.
However, being new to c# (am a c++ developer) I need to know how to pass the data from these threads to the one processing thread, which will take the message and process it.
I was think ing of delegates, where each thread has a pointer to a callback function on the processing thread and then just pass the message in as a parameter.
Also possibly thinking of havoing a global collection that all the queses can see and the listening quese push messages on and then send an event to the processing thread to wake it up which then pops the message off the queue , however, this is at risk of race conditions.
Any help you can give would be most helpgful
|All times are GMT +5.5. The time now is 02:46.|