Threading

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

    #1

    Threading

    I'm wanting a loop that executes threads via BeginInvoke. The user can
    control the number of threads they want, on the fly. Anybody know a good
    scheme on how to do this? I was using the Interlocked class to increment
    when I call BeginInvoke and a decrement when the thread was done, to know
    when all of the threads are done executing, and the ammount of current
    threads. This appears to fail sometimes, therefore I'm looking for a
    different logic model. Any help would be great.

    JB


  • Dave

    #2
    Re: Threading

    You could use the threadpool and let it manage the number of threads for
    you. It was designed specifically to manage the number of threads, and also
    handles details that most people would find it difficult to get correct,
    such as thread decay, security, etc. If you don't like the runtime's
    implementation there are plenty of code samples around the internet that you
    could use as the basis of your own.

    "JB" <jasonb@bellevu e.com> wrote in message
    news:Qo%cb.1355 0$KJ4.9048@news 1.central.cox.n et...[color=blue]
    > I'm wanting a loop that executes threads via BeginInvoke. The user can
    > control the number of threads they want, on the fly. Anybody know a good
    > scheme on how to do this? I was using the Interlocked class to increment
    > when I call BeginInvoke and a decrement when the thread was done, to know
    > when all of the threads are done executing, and the ammount of current
    > threads. This appears to fail sometimes, therefore I'm looking for a
    > different logic model. Any help would be great.
    >
    > JB
    >
    >[/color]


    Comment

    Working...