Hi
I have a problem with a winforms app. I have a timer (autoReset) which on elapsed updates a lable on my form. When I close the form I get an error stating "Cannot access a disposed object"
Here is the method I call on the timer event:
private void upDateTimeData()
{
if (!(this.Disposing))
{
try
{
if (this.InvokeRequired)
{
{
this.Invoke((MethodInvoker)delegate() { this.upDateTimeData(); });
}
}
else
{
label_TCGDate.Text = masterClock.TCGDate.ToShortDateString();
label_TCGTimecode.Text = masterClock.TCG.ToString();
}
}
catch (Exception e)
{
Console.WriteLine("Form Error: " + e.Message);
//Form Closing.
}
}
}
I have tried unregestering the timer event in the form closing event, but that did not help.
Does anyone know of the best way of dealing with cross thread delegation and form closing?
Thanks for your time Guy's.
John.