Here's a sample of InvokeRequired/BeginInvoke.  I had to dig around my code
to find one that I use.  Modify it as needed to suit your needs.

      private delegate void UpdateTxtDelegate(String Txt);
      private void UpdateTxt(String Txt)
      {
         if (this.InvokeRequired)
         {
            this.BeginInvoke(new UpdateTxtDelegate(UpdateTxt),
                                    new object[] { Txt });
            return;
         }
         txtBox.Text += Txt;
      }

...Glenn
On Fri, Oct 31, 2008 at 3:03 PM, Glenn <[EMAIL PROTECTED]> wrote:

> You are getting that error because you are attempting to update a control
> from another thread.
>
> The best way to handle this is with delegates.  You utilize the
> InvokeRequired/BeginInvoke methods to transfer the update request from the
> background thread to the UI updater thread.
>
> ...Glenn
> On Fri, Oct 31, 2008 at 2:19 PM, Dickery1 <[EMAIL PROTECTED]> wrote:
>
> i get a error cross thread operation not valid when it is trying to
> write to the textfield.
>

Reply via email to