Search code examples
wpfasynchronousbackgroundworkerbegininvoke

Can BeginInvoke do the same thing as BackgroundWorker?


Can BeginInvoke do the same thing as a BackgroundWorker ? I mean aren't both having the same goal in the end which is doing async operations in a different thread ?

If i have a WPF windows.. and i want to access database using both methods. Is the effect going to be the same ?


Solution

  • You can replace BackgroundWorker with BeginInvoke, but it will take some additional code BackgroundWorker wraps up the management of the background thread in a pretty friendly way.

    BeginInvoke can certainly take care of doing work asynchronously. It's a bit lower level, so you have some more flexibility (at the price of having to do more of the work yourself).