Hi,
The problem is that the line -
this.Invoke(new MyDelegate(Func tion), args); // this = MainForm
is being called after the line -
terminatePopula te = true;
therefore I get an exception which states that MainForm has been
disposed when this.Invoke is called...
Is there a way to check if MainForm has been disposed. Perhaps theres
a better way of doing what am trying to achieve,
Thanks,
Aine
public class FormMain : Form
{
volatile bool terminatePopula te = false;
void FormMain_Load()
{
myThread = new System.Threadin g.Thread(MyThre ad());
myThread.Start( );
}
void MyThread()
{
while (!anotherObject .ContinueWaitin g)
{
if (!terminatePopu late)
this.Invoke(new MyDelegate(Func tion), args); // concerned
with control on Main Form
else
return;
Thread.Sleep(10 0); // Updates a control every 100 ms
}
if (!terminatePopu late)
this.Invoke(new MyOtherDelegate (Function), args);
}
private void OnClosing(objec t sender, EventArgs ev)
{
terminatePopula te = true;
}
}