H
Hilton
Hi,
Here is the code:
DialogResult dialogResult = dgid.ShowDialog ();
XYZInfo xyzInfo = dgid.XYZInfo;
dgid.ShutDown ();
dgid.Dispose();
Pretty strightforward. The dialog has Windows timer to show the current
time. ShutDown calls this.timer.Enabled = false;. Sometimes, I get an
ObjectDisposedException. My thinking is that the dialog's timer adds a
(tick) message to the queue. ShutDown() disables the timer, and Dipose()
nukes the dialog. However, that tick message is still sitting in the queue.
When Windows gets around to processing the tick message, the form has been
disposed and I get the ObjectDisposedException. Does this sound right?
Assuming I am on the right track, how should I dispose of this form safely
so that no timer messages are left in the queue? Secondly, do I really need
to call Dispose or should I just let nature (GC) runs its course?
Thanks,
Hilton
Here is the code:
DialogResult dialogResult = dgid.ShowDialog ();
XYZInfo xyzInfo = dgid.XYZInfo;
dgid.ShutDown ();
dgid.Dispose();
Pretty strightforward. The dialog has Windows timer to show the current
time. ShutDown calls this.timer.Enabled = false;. Sometimes, I get an
ObjectDisposedException. My thinking is that the dialog's timer adds a
(tick) message to the queue. ShutDown() disables the timer, and Dipose()
nukes the dialog. However, that tick message is still sitting in the queue.
When Windows gets around to processing the tick message, the form has been
disposed and I get the ObjectDisposedException. Does this sound right?
Assuming I am on the right track, how should I dispose of this form safely
so that no timer messages are left in the queue? Secondly, do I really need
to call Dispose or should I just let nature (GC) runs its course?
Thanks,
Hilton