Question on Dispose and SelectNextControl

G

Guest

Hey guys,

I'm having some weird issues when calling Dispose on one of the controls in
a user control from an asycn or sync method. When called form an async
method Dispose makes a call to SelectNextControl but not when called from a
sync method. I'm trying to figure out why that is so.

Does anyone know under what conditions Dispose will call SelectNextControl?

I have a breakpoint set on the user controls OnValidated method and when the
dispose is called async I see the below stack trace. When called sync the
breakpoint is not hit (since the user control doesn't lose focus from a
SelectNextControl call).

Here is a sample stack trace:

system.windows.forms.dll!System.Windows.Forms.Control::Select(bool directed
= true, bool forward = true) + 0x32 bytes

system.windows.forms.dll!System.Windows.Forms.Control::SelectNextControl(System.Windows.Forms.Control
ctl = {Controls.Common.AmountControl}, bool forward = true, bool tabStopOnly
= true, bool nested = true, bool wrap = false) + 0xba bytes

system.windows.forms.dll!System.Windows.Forms.ContainerControl::Select(bool
directed = true, bool forward = true) + 0x9d bytes

system.windows.forms.dll!System.Windows.Forms.Control::SelectNextControl(System.Windows.Forms.Control
ctl = {Quote.Controls.QuoteControlAdv}, bool forward = true, bool tabStopOnly
= true, bool nested = true, bool wrap = true) + 0xba bytes

system.windows.forms.dll!System.Windows.Forms.ContainerControl::AfterControlRemoved(System.Windows.Forms.Control
control = {Calendar.Controls.PopupCalendar}) + 0x186 bytes

system.windows.forms.dll!System.Windows.Forms.Control::ControlCollectionRemove(System.Windows.Forms.Control
value = {Calendar.Controls.PopupCalendar}) + 0x102 bytes
system.windows.forms.dll!System.Windows.Forms.Control::Dispose(bool
disposing = true) + 0x1db bytes

system.windows.forms.dll!System.Windows.Forms.ContainerControl::Dispose(bool
disposing = true) + 0x2f bytes
 
G

Guest

It calls it if the control your are disposing or one of its decendant
controls is the active control on the form.

Ciaran O'Donnell
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top