Asynchronous WPF Command
The ICommand interface provides a nice way of binding WPF buttons to methods in a view model. If those methods use any amount of time, though, you'll want to run them in a background thread.
This implementation of ICommand is an easily-extendable way to run methods in an async manner when a button is clicked. The base class creates a BackgroundWorker that runs a proxy for the Execute method. All you have to do is override OnExecute.
method allows you to run operations on the UI thread immediately before the BackgroundWorker does its async operation.
method allows you to run operations after the BackgroundWorker completes its work. It also provides the Exception object (if one was thrown) that was thrown in the background thread.