GUI and Threading

Posted by cam on Stack Overflow See other posts from Stack Overflow or by cam
Published on 2010-04-20T14:21:22Z Indexed on 2010/04/20 14:33 UTC
Read the original article Hit count: 265

Filed under:
|

Isn't there a better way to handle GUI (WinForms) from another thread than creating a delegate for every single method I need to use? It seems like there would be a better way.

Here's the current code I use for every single GUI method:

    private delegate void SetStatusTextDelegate(string set_text);

    public void SetStatusText(string set_text)
    {
        if (status_prog.InvokeRequired)
        {
            status_prog.Invoke(new SetStatusTextDelegate(SetStatusText), set_text);
        }
        else
        {
            status_prog.Text = set_text;
        }
    }

© Stack Overflow or respective owner

Related posts about c#

Related posts about threading