updating inactive form.text from a thread in c#
<p>I'm trying to update form.text from a thread. Basically thread need to update the form.text with the current time. my code looks like below </p>

<pre><code>UpdateText("My Monitor (Last Updated " + DateTime.Now.ToString("HH:mm:ss tt") + ")", Form1.ActiveForm);
</code></pre>

<p>and the method as below </p>

<pre><code>    void UpdateText(String s, Control c)
    {
        if (c.InvokeRequired)
        {

            this.BeginInvoke(new MethodInvoker(() =&gt; UpdateText(s, c)));

        }
        else
        {
            c.Text = s;
        }
    }
</code></pre>

<p>As long as the main application window is active, code works. If the application becomes inactive, then I get the error "Object reference not set to an instance of an object"</p>
