Multiple Request Processor

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Karthik D V

    #1

    Multiple Request Processor

    Hi All,
    I have the following requirement.

    I have table which contains requestID, priority and the request
    status(status can be 'Queued','Proce sing','Complete d','Failed')

    I need a class which takes 5 top priority requests and process the
    same simultaniously, now if any of these requests completed, for the
    same slot I should get the next priority requests to process.

    How do I do this? I thought og doing using ThreadPool, but in
    threadPool we dont have the facility to know whether the given thread
    is completed or not :(

    Please help me in this regard.

    Thank you.

  • =?ISO-8859-1?Q?G=F6ran_Andersson?=

    #2
    Re: Multiple Request Processor

    Karthik D V wrote:
    Hi All,
    I have the following requirement.
    >
    I have table which contains requestID, priority and the request
    status(status can be 'Queued','Proce sing','Complete d','Failed')
    >
    I need a class which takes 5 top priority requests and process the
    same simultaniously, now if any of these requests completed, for the
    same slot I should get the next priority requests to process.
    >
    How do I do this? I thought og doing using ThreadPool, but in
    threadPool we dont have the facility to know whether the given thread
    is completed or not :(
    >
    Please help me in this regard.
    >
    Thank you.
    >
    Use an array of Thread objects, and monitor the ThreadState property of
    them.

    --
    Göran Andersson
    _____
    Göran Anderssons privata hemsida.

    Comment

    • Peter Duniho

      #3
      Re: Multiple Request Processor

      Karthik D V wrote:
      Hi All,
      I have the following requirement.
      >
      I have table which contains requestID, priority and the request
      status(status can be 'Queued','Proce sing','Complete d','Failed')
      >
      I need a class which takes 5 top priority requests and process the
      same simultaniously, now if any of these requests completed, for the
      same slot I should get the next priority requests to process.
      >
      How do I do this? I thought og doing using ThreadPool, but in
      threadPool we dont have the facility to know whether the given thread
      is completed or not :(
      >
      Please help me in this regard.
      It seems to me that a simple approach would be to use the
      BackgroundWorke r class, handle the RunWorkerComple ted event, and in your
      handler, start a new BackgroundWorke r from your queue of prioritized
      requests.

      You would initialize the whole thing by starting five BackgroundWorke rs
      initially, and then only starting a new BackgroundWorke r after that in
      your RunWorkerComple ted event handler.

      If you have the ability to add new requests after processing has
      started, then you would want to keep a counter of the active requests
      (add one when you start a BackgroundWorke r, subtract one in the
      RunWorkerComple ted event handler), and allow for a new requests to be
      started as it's added if you are under your maximum of five.

      Pete

      Comment

      Working...