Passing data / events between two worker threads in c#

Discussion in 'C#' started by anthonym, Mar 1, 2012.

  1. anthonym

    anthonym New Member

    Joined:
    Mar 1, 2012
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Hi,

    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

    thanks
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice