Any ideas?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mullin Yu

    #1

    Any ideas?

    I want to have a controller class to do

    - initilization: create a thread pool with max 10 thread
    - get ten records from the db every time
    - assign each record to one thread

    worker thread
    - do the application logic
    - once finish, tell the controller class

    once all the ten worker threads finish the job, the controller gets the next
    batch of ten records from the db, and then assign to the worker thread

    1. is it a good design?
    2. any pattern i can use
    3. any simple coding on the web illustrating the concept of setting max
    thread no., controller knows all the worker thread finished the job

    thanks!



  • Dmitriy Lapshin [C# / .NET MVP]

    #2
    Re: Any ideas?

    Hi,

    As far as I know, the number of threads in the thread pool cannot be set at
    run time and is governed by a setting in the machine.config file. Then,
    there seems to be no sense in paralleling jobs competing for the same
    hardware resource - one physical printer cannot print two documents
    simultaneously (but who knows, may be yours can :-) - the same is true for
    fax. So I would probably start three threads - one for printer, one for fax
    and one for e-mail and would establish three thread-safe queues where jobs
    of the appropriate type would be added.

    --
    Dmitriy Lapshin [C# / .NET MVP]
    X-Unity Test Studio

    Bring the power of unit testing to VS .NET IDE

    "Mullin Yu" <mullin_yu@ctil .com> wrote in message
    news:uMGUh2RmDH A.2732@TK2MSFTN GP11.phx.gbl...[color=blue]
    > I want to have a controller class to do
    >
    > - initilization: create a thread pool with max 10 thread
    > - get ten records from the db every time
    > - assign each record to one thread
    >
    > worker thread
    > - do the application logic
    > - once finish, tell the controller class
    >
    > once all the ten worker threads finish the job, the controller gets the[/color]
    next[color=blue]
    > batch of ten records from the db, and then assign to the worker thread
    >
    > 1. is it a good design?
    > 2. any pattern i can use
    > 3. any simple coding on the web illustrating the concept of setting max
    > thread no., controller knows all the worker thread finished the job
    >
    > thanks!
    >
    >
    >[/color]

    Comment

    • Willy Denoyette [MVP]

      #3
      Re: Any ideas?

      "Dmitriy Lapshin [C# / .NET MVP]" <x-code@no-spam-please.hotpop.c om> wrote in message news:umyBM4SmDH A.1740@TK2MSFTN GP12.phx.gbl...[color=blue]
      > Hi,
      >
      > As far as I know, the number of threads in the thread pool cannot be set at
      > run time and is governed by a setting in the machine.config file.[/color]

      **** You can change the values at run time through COM interop, just call ICorThreadPool: :CorSetMaxThrea ds (see mscoree.h).
      The machine.config file threadpool values are only used by the asp.net host.

      Willy.


      Comment

      Working...