Thread object vs Threadpool?

Discussion in 'ASP .Net' started by mortb, Jan 20, 2006.

  1. mortb

    mortb Guest

    Hi all!

    In my webb app I'm about to introduce a way of processing long running tasks
    in the background.
    As the long running task gathers data from a database process them and
    compile them into a file appx 80 mbytes large it is a resource demanding
    task both of the CPU and the memory.
    So I think I should restrict how many of these tasks that should be able to
    start and make them run in the background.

    First I read about the Thread class and thougth: Fine I'll use a thread and
    then I'll write a utility class that will queue the tasks and make them run
    either one after one or not too many at a time.
    I'd set threads' priority to belowNormal or lowest.

    Then I discovered the threadpool class and thought: Hey here's the queuing
    abillity I was looking for. But then I found no way of setting the priority
    of the thread that would start the long running task and I don't want to
    make the web pages serve slowly.

    Does anyone have any advice on whether I should use the threadpool or create
    thread objects "on my own" in the code?

    Thanks in advance!
    mortb
     
    mortb, Jan 20, 2006
    #1
    1. Advertising

  2. ThreadPool class is mostly used for fire and forget tasks.
    Use Thread class if extended control is needed.
    -
    Milosz Skalecki
    MCP, MCAD


    "mortb" wrote:

    > Hi all!
    >
    > In my webb app I'm about to introduce a way of processing long running tasks
    > in the background.
    > As the long running task gathers data from a database process them and
    > compile them into a file appx 80 mbytes large it is a resource demanding
    > task both of the CPU and the memory.
    > So I think I should restrict how many of these tasks that should be able to
    > start and make them run in the background.
    >
    > First I read about the Thread class and thougth: Fine I'll use a thread and
    > then I'll write a utility class that will queue the tasks and make them run
    > either one after one or not too many at a time.
    > I'd set threads' priority to belowNormal or lowest.
    >
    > Then I discovered the threadpool class and thought: Hey here's the queuing
    > abillity I was looking for. But then I found no way of setting the priority
    > of the thread that would start the long running task and I don't want to
    > make the web pages serve slowly.
    >
    > Does anyone have any advice on whether I should use the threadpool or create
    > thread objects "on my own" in the code?
    >
    > Thanks in advance!
    > mortb
    >
    >
    >
     
    =?Utf-8?B?TWlsb3N6IFNrYWxlY2tp?=, Jan 20, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. bruce barker

    Re: ThreadStaticAttribute and threadpool

    bruce barker, Jul 11, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    553
    bruce barker
    Jul 11, 2003
  2. David Browne

    Re: ThreadStaticAttribute and threadpool

    David Browne, Jul 11, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    462
    David Browne
    Jul 11, 2003
  3. Scott Allen
    Replies:
    1
    Views:
    1,981
    Henri
    Dec 14, 2004
  4. Douwe
    Replies:
    0
    Views:
    742
    Douwe
    Dec 8, 2005
  5. Franck

    Change Max number of thread in threadpool

    Franck, Apr 25, 2005, in forum: ASP .Net Web Services
    Replies:
    1
    Views:
    150
    Brock Allen
    Apr 25, 2005
Loading...

Share This Page