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!
mortbThreadPool 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 tas
ks
> 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 t
o
> start and make them run in the background.
> First I read about the Thread class and thougth: Fine I'll use a thread an
d
> then I'll write a utility class that will queue the tasks and make them ru
n
> 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 priorit
y
> 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 crea
te
> thread objects "on my own" in the code?
> Thanks in advance!
> mortb
>
>
Thursday, March 22, 2012
Thread object vs Threadpool?
Labels:
allin,
app,
asp,
background,
gathers,
net,
object,
processing,
running,
task,
tasksin,
threadpool,
webb
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment