BackgroundWorker vs. Asynch delegate method and BeginInvoke thread

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,

I need to create a background thread and two (or more) options are available
to me:

1. BackgroundWorker
2. Asynch delegate method and BeginInvoke

What are the differences between them in performance, complexity etc.

Thanks,
EitanB
 
Eitan said:
Hello,

I need to create a background thread and two (or more) options are
available to me:

1. BackgroundWorker
2. Asynch delegate method and BeginInvoke

What are the differences between them in performance, complexity etc.

BackgroundWorker is easier. Unless you have some specific reason to not use
it, that's probably your best choice.

Async delegate uses the thread pool just as BackgroundWorker does, but it's
harder to use, will have no difference in performance, and is more complex.

-cd
 
Carl, Tanks
EitanB

Carl Daniel said:
BackgroundWorker is easier. Unless you have some specific reason to not use
it, that's probably your best choice.

Async delegate uses the thread pool just as BackgroundWorker does, but it's
harder to use, will have no difference in performance, and is more complex.

-cd
 
I disagree. If you want to just execute an action, without cancelling
or notification while that action is performing on another thread, then I
would say using an asynchronous delegate call, the Thread class, or the
ThreadPool is much easer than the BackgroundWorker class.

If you need updates from the background thread, and/or the ability to
cancel, then the BackgroundWorker is the best option.
 
Hello,

Thanks for your anser.

My thead will communicate (send command/recieve status) through the
Ethernet. The status is a byte array, which I need to display on the screen.

EitanB

Nicholas Paldino said:
I disagree. If you want to just execute an action, without cancelling
or notification while that action is performing on another thread, then I
would say using an asynchronous delegate call, the Thread class, or the
ThreadPool is much easer than the BackgroundWorker class.

If you need updates from the background thread, and/or the ability to
cancel, then the BackgroundWorker is the best option.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Carl Daniel said:
BackgroundWorker is easier. Unless you have some specific reason to not
use it, that's probably your best choice.

Async delegate uses the thread pool just as BackgroundWorker does, but
it's harder to use, will have no difference in performance, and is more
complex.

-cd
 
Nicholas said:
I disagree. If you want to just execute an action, without
cancelling or notification while that action is performing on another
thread, then I would say using an asynchronous delegate call, the
Thread class, or the ThreadPool is much easer than the
BackgroundWorker class.

Then you agree. In the case you describe, you have a specific reason not to
use BackgroundWorker - your use case does not fit well with the
BackgroundWorker model.

-cd
 
Back
Top