The two are not identical, as you can easily see by looking at the implementation of Control. Dispose using Reflector (easy to do while it's still free! ) For example, if you just call Dispose on your panel, it will call DisposeAxControls on each child control, and remove itself from its parent, before calling Dispose on its children Nevertheless I agree with Cody Gray - you need to work out why it's freezing rather than trying to "sweep the problem under the carpet" with your proposed workaround Normally you don't call Dispose on a Panel explicitly - if you are doing so, you need to be sure you're managing the lifetime and ownership of your controls correctly The thing to do is to start simplifying your app step by step until it no longer freezes - to work out what is causing the freeze (for example, by removing the Timers you mentioned one by one - that sounds suspect).
Once you have a very simple example that exhibits the problem it will be easier for you (or someone here) to work out what's going on.
The two are not identical, as you can easily see by looking at the implementation of Control. Dispose using Reflector (easy to do while it's still free! ) For example, if you just call Dispose on your panel, it will call DisposeAxControls on each child control, and remove itself from its parent, before calling Dispose on its children.
Nevertheless I agree with Cody Gray - you need to work out why it's freezing rather than trying to "sweep the problem under the carpet" with your proposed workaround. Normally you don't call Dispose on a Panel explicitly - if you are doing so, you need to be sure you're managing the lifetime and ownership of your controls correctly. The thing to do is to start simplifying your app step by step until it no longer freezes - to work out what is causing the freeze (for example, by removing the Timers you mentioned one by one - that sounds suspect).
Once you have a very simple example that exhibits the problem it will be easier for you (or someone here) to work out what's going on.
Yes, disposing the container will automatically dispose of its child controls. According to the MSDN documentation, the Control. Dispose method: Releases the unmanaged resources used by the Control and its child controls and optionally releases the managed resources.So calling the Dispose method on the Panel control will automatically dispose its child controls.
However, there is an important caveat to this, as noted by Joe's comment: the child controls must have unsubscribed from events that are declared outside of the parent's scope. If the events are members of objects that will stay alive, they will keep the child controls alive as well and prevent them from being properly disposed. Obviously you don't need to unsubscribe from events declared in objects that are being disposed of simultaneously, such as the parent.
Of course, it's also worth nothing that this can be extended to the Panel control's container (most likely a Form control). Whenever you Dispose the Form that owns the Panel, both the Panel control and all of its children will be disposed for you automatically. There's no reason to do so explicitly for the Panel control, unless you're adding and removing instances to and from your form dynamically.
That's interesting. What do you mean by "owns the Panel" because what I do is create a control and then add it to the form. And with this method, if I were to dispose the form, the timers on the controls that were added will keep firing.
I'm guessing the key here is ownership, how do you get the parent to own a child that's not declared from within the designer. Cs file of the form. – Joe Feb 4 at 4:45 @Joe: You've thrown a wrench into things when you said "timers".
How did you add the timers to the controls? There's no guarantee that the timers will be disposed when the controls themselves are, because they're not necessarily owned by the control. – Cody Gray Feb 4 at 4:49 hum... my timers are created from the constructor within the control that's added to the form.So there shouldn't be scoping issues there... – Joe Feb 4 at 5:05 @Cody - Do you know if it'll do anything extra in that first example?
– Smashery Feb 4 at 5:41 @Smashery: I'm not sure that I know what you mean. What first example? What sort of extra things?
There's nothing magical that goes on. – Cody Gray Feb 4 at 5:44.
Yes, disposing the container will automatically dispose of its child controls. According to the MSDN documentation, the Control. Releases the unmanaged resources used by the Control and its child controls and optionally releases the managed resources.
So calling the Dispose method on the Panel control will automatically dispose its child controls. However, there is an important caveat to this, as noted by Joe's comment: the child controls must have unsubscribed from events that are declared outside of the parent's scope. If the events are members of objects that will stay alive, they will keep the child controls alive as well and prevent them from being properly disposed.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.