Update GUI controls from a background thread of another class
<p>I am creating an windows based application which download the data from server.
I am using background thread which is created on different class to perform these download operation.And I want to continuously show the download status on rich textbox i.e on main thread.But i am unable to do this,get an Cross-thread operation not valid.
Please help me to resolve this problem.</p>

<p>method on Form1.cs</p>

<pre><code>public void UpdateRichText(string Text)
{
    SetRichText(Text);                     
}

public delegate void SetRichTextTextDelegate(string text);
public void SetRichText(object number)
    {            
        if (InvokeRequired)
        {                
            this.BeginInvoke(new SetRichTextTextDelegate(SetRichText),text);                
            return;
        }

        richTextBox1.Text += number.ToString() + "\n";
    }
     private void button3_Click_1(object sender, EventArgs e)
    {
        demo d = new demo();
        d.display();
    }
</code></pre>

<p>methods on demo.cs</p>

<pre><code>    Form1 f = new Form1();
    public void display()
    {      
        Thread t = new Thread(new ThreadStart(call));
        t.Start(); 
    }


    public void call()
    {
    //when i call this method every time if(InvokeRequired) is false.
        f.UpdateRichText("Called from Thread");
    }
</code></pre>
