Rene Nielsen

Rene Nielsen

  • NA
  • 22
  • 31.5k

Seperate thread invoke problem

Mar 15 2011 5:31 PM
Hey i have created a Usercontrol for a scrolling text field.

the problem is when u insert this control on a form and the user chooses to close the form it starts disposing the objects
if my 2nd thread running the text on the usercontrol then is in the middle of invoking the textBox object i get an error.
this is due to the fact that it has been disposed. 

The problem is i cant stop it from getting that error because it sometimes gets stuck at the position i posted below.
The 2nd thread has already passed the arguments supposted to stop it from doing it if the object is disposed or dosent need to be invoked
and it throws an error

if(Running)
{
        if(this.InvokeRequired)
        {
 HERE   ->  this.Invoke(new InvokeDelegate(delegate
                {
                        textBox1.Text = theNewText;
                }));
        }
}
                

Attachment: floatingtext.zip

Answers (1)