Jonas Yans
7/11/2008 2:34:00 AM
On 7?11?, ??9?00?, "Peter Duniho" <NpOeStPe....@nnowslpianmk.com>
wrote:
> On Thu, 10 Jul 2008 13:55:31 -0700, <carl.claw...@pkinetics.com> wrote:
> > On Jul 10, 12:52 pm, Family Tree Mike
> > <FamilyTreeM...@discussions.microsoft.com> wrote:
> >> It would seem to make sense that you would have issues if you don't
> >> dispose
> >> something that can be disposed.
>
> > I don't expect to have to dispose things explicitly unless there's a
> > reason that I need to have it done at a specific point in the code.
> > That's what the garbage collector is for.
>
> This is categorically WRONG.
>
> Jack's reply addresses this, but because it's so important, let me be very
> clear: if an object implements IDisposable, it's _essential_ that you call
> Dispose() on the object when you're done with it. The garbage collector
> is for releasing _managed_ memory. _Disposing_ objects is the exact
> opposite of "what the garbage collector is for".
>
> Pete
1. Create a UserControl
2. add a ToolStrip to the UserControl
3. add a ToolStripTextBox(or a ToolStripComboBox) to the UserControl
4. Create a form and add the UserControl to the form(remeber as Class
Form2)
5.Create another form(remeber as Class Form1)
6. add a button1 to form1.
7.create button1_Click
private void button1_Click(object sender, EventArgs e)
{
using (Form2 f = new Form2())
{
f.ShowDialog();
}
}
evertime click the button to show Form2,u can see GDI objects+1(Use
Windows Task Manager)
in this case,do i need Dispose this ToolStripTextBox?