Return to Snippet

Revision: 31193
at September 1, 2010 01:12 by yasbas


Updated Code
using System.Threading;

private void btnStart_Click(object sender, EventArgs e)
{
    Thread t = new Thread(new ThreadStart(this.AsyncGetResults));
    t.Start();
}

private void AsyncGetResults()
{

    // Do some not-GUI-touching stuff 
    // ...

    // So some GUI-touching stuff
    if (panellWait.InvokeRequired)
    {
        panelWait.Invoke(new MethodInvoker(delegate
        {
            panelWait.Visible = true;
        }));
    }

    // Do some other not-GUI-touching stuff 
    // ...
}

Revision: 31192
at September 1, 2010 01:11 by yasbas


Initial Code
private void btnStart_Click(object sender, EventArgs e)
{
    Thread t = new Thread(new ThreadStart(this.AsyncGetResults));
    t.Start();
}

private void AsyncGetResults()
{

    // Do some not-GUI-touching stuff 
    // ...

    // So some GUI-touching stuff
    if (panellWait.InvokeRequired)
    {
        panelWait.Invoke(new MethodInvoker(delegate
        {
            panelWait.Visible = true;
        }));
    }

    // Do some other not-GUI-touching stuff 
    // ...

}

Initial URL

                                

Initial Description

                                

Initial Title
WinForms start thread that can access the GUI

Initial Tags

                                

Initial Language
C#