Jason Olson on Threading in Avalon
Jason Olson, an enterprising 3rd party, posts a look at the benefits of knowing about threading when building an entire UI stack from scratch. Instead of requiring you to transition from a worker thread to the UI thread to talk to a control, Avalon lets you grab the UI context that owns the control and party on:
void ShowProgress(int secondsElapsed) {
try {
this.Context.Enter();
txtSeconds.Text = secondsElapsed.ToString();
}
finally {
this.Context.Exit();
}
}
This is far simpler code than what would be required in code based on User32. Nice.
UPDATE: Ian Griffiths points out that the code can be even sweeter!