# Updating GUI from different threads – Part 2

- Link: https://saguiitay.com/updating-gui-from-different-threads-part-2/
- Published: 2007-09-10T09:08:00+03:00
- Author: Itay

As part of my work at [Tzunami Inc.](https://www.tzunami.com/), I’m working on migrating
our product Deployer – a [SharePoint migration](https://www.tzunami.com/products)
tool – from .Net 1.1 to .Net 2.0 and Visual Studio 2005.

One of the first things we’ve encountered was the managed debugging assistants (
MDA). I’ll talk about the MDAs in a later entry, but for now, let’s just say that
those are exceptions that are thrown only in debug mode, and that assist you in 
finding bugs and problematic points in your code that are otherwise hard to locate.

The first MDA that we’ve encountered was the Cross-thread operation not valid. What
this means, is that you’re trying to update the GUI from a thread other than the
thread that created the GUI control. You can read about how to solve this issue 
in .Net 1.1 in one of my previous entries.

However, .Net 2.0 allows you to resolve this in a much cleaner way. Below is the
way we decided to handle this:

    ```notranslate
    private void InvokeGuiDelegate(GUIDelegate d)
    {
        if (InvokeRequired)
            BeginInvoke(d);
        else
            d();
    }
    ```

Now we can use the above method everywhere we need to update the GUI, using an anonymous
method:

    ```notranslate
    InvokeGuiDelegate( delegate() { numericUDTimeout.Value = value; });
    ```

### _Related_
