Username:   Password:  

Access forms by a thread

delegate void WriteStatusCallback(string statusMsg); 
 
public void WriteStatus(string statusMsg)
{
    if (InvokeRequired)
    {
        Invoke(new WriteStatusCallback(WriteStatus), new Object[] { statusMsg });
    }
    else
    {
        // Access Windows forms control
    }
}

Accessing Windows forms controls needs special handling by the Invoke() function.

Tags

C# CSharp threads invoke windows forms