A BackgroundWorker for Avalon

I saw a post at the winfx.avalon newsgroup about the lack of support for a BackgroundWorker in Avalon (at least for v1.0). Since I need something like this for calling the Web Services asynchronously and then updating the Graphical User Interface, I just created a very simple one.

public class BackgroundWorker

{

  private UIContext _context;

  private UIContextOperationCallback _callback;

  public BackgroundWorker(UIContextOperationCallback callback)

  {

    _context = UIContext.CurrentContext;

    _callback = callback;

    Thread thread = new Thread(new ThreadStart(_run));

    thread.Start();

  }

  private void _run()

  {

    _context.Invoke(_callback, null);

  }

}

For the benefit of those who haven’t done any Windows GUI programming before, I have to say that a pattern like this is necessary because all the GUI elements must be updated by the same thread. The above makes sure that this happens.

UPDATE: Formatting fixed.

Recent Posts

CVOYA Graph v1.0 is out

Last week, I wrote about the evolution of the CVOYA Graph. After a lot of…

4 weeks ago

CVOYA Graph – Evolution

Last year, I released the "Graph Model" library for .NET as an open source project. It…

1 month ago

The boat is in the water: Spring Voyage is open source

Today I'm pushing Spring Voyage out of the harbor. You can track its journey on…

3 months ago

My Coding Agent Needed Its Own GitHub Identity

In my last post, I wrote that "the typing of code was parallelized and delegated.…

4 months ago

Rebuilding My AI Team in Twelve Days — And Why

In February, I wrote about the small team I'd stood up instead of hiring humans:…

4 months ago

How I Built My Own Team of AI Developers

Assembling a dream team without a single hire I've been making great progress on CVOYA's…

6 months ago