Thread Reuse

  • Thread starter Thread starter wackyphill
  • Start date Start date
W

wackyphill

If I am going to have a BG thread do a job on a button click. Is it
better to create the thread on each click, or make it a a member and
reuse it by starting it on each click?
 
Reuse is your best bet ! This way u can check if processing has been
completed for prev request (enable / disable request button) and if so
perform next operation.
Ashish
 
If I am going to have a BG thread do a job on a button click. Is it
better to create the thread on each click, or make it a a member and
reuse it by starting it on each click?

The code is likely to be simpler by creating a new thread. If your work
is going to be very short, you could use the ThreadPool to get
automatic reuse, but personally I'd just create a new thread if it's a
case of reacting to a button click. It's not like the performance hit
of creating a new thread will be significant if it's only happening
once every time a user manually does something.
 
Back
Top