9 people following this project (follow)

Project Description
The Mantra "Never block the UI thread!" results in cumbersome helpers like the Backgroundworker with worker and callback delegates.

The AsyncExecutor offers an alternative: It allows to switch between UI and worker thread in a single method! I.e. no cumbersome callback etc.


Summary
In a method like this:

PersonCollection.Clear();
StatusMessage = "Loading Persons...";
List<string> persons = provider.GetPersons();
foreach (var name in persons)
{
     PersonCollection.Add(new Person { Name = name });
}
StatusMessage = "Finished loading persons";


the method provider.GetPersons might take some time (e.g. seconds).
During this time the UI thread is blocked. That shall be avoided under all circumstances.

A BackgroundWorker could be used to address this.
But it is cumbersome to use: It uses delegates for worker and callback. It's not type safe. There is only a single result of the worker. Etc.

The AsyncExecutor allows to simplify this to use a single method with statements in the method which are used to indicate a thread switch.

It's even possible to switch e.g. in a loop - which is VERY cumbersome using a background worker.

Last edited Nov 4 2011 at 10:08 AM by RalfHoffmann, version 4