views:

60

answers:

1

I'm updating a WinForms application that uses a BackgroundWorker to do something useful when a button is pressed.

The trouble is, "something useful" iterates sequentially through a long list of things to do, and can take quite a while to complete.

I'm considering having the button press event create multiple BackgroundWorkers instead of one or having the current BackgroundWorker create additional BackgroundWorkers to do the actual work.

Both approaches seem fairly equivalent to me.

Are there advantages/disadvantages to either one? Is there a better way to do this?

+1  A: 

Have you looked at using the background worker with Parallel.For? (Parallel.For @ msdn)

Managing the multiple workers could be an issue - that's the kind of thing the Parallel extensions do...

PK :-)

Paul Kohler
That's a very nice suggestion! I'll have a look and see how easy it is to apply.
Eric J.
It was amazingly easy to change my existing loop. Reading, learning curve, implementation and test took 18 minutes.
Eric J.
.net 4 has some really great stuff in it! :-)
Paul Kohler