Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to dispose a DialogForm and its object when closed
Message
 
To
06/05/2005 02:45:33
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
01011518
Message ID:
01011587
Views:
14
How are you closing the dialog form? The "correct" way to close is to assigning its DialogResult property to something (OK or Cancel.) As you probably already know, assigning the DialogResult property automatically closes the form.

You might run into problems if you try to close/hide the form directly. It seems to work better if you just assign DialogResult property.

You do need to always dispose the form in the caller code, though. Regardless of whether the use selected OK or Cancel.
homeForm = new Form_Address1("Home Address);
if (homeForm.ShowDialog(this) == DialogResult.OK)
{
    /* do something */
}
homeForm.Dispose(); // always dispose
>Hi Guys,
>
>Im currently developing an application in C#. I created a class for my dialog form and compiled it as DLL. I then instantiate my dialog form from the dll.
>
>One thing I noticed in my program is that the longer I used it, the slower the application goes. I tried to check my memory in the Task Manager(Performance Tab). I noticed that everytime I click a button that calls my dialog form, the PF Usage gradually increases. If I close the dialog form, the memory is not released. I tried to strain the program and the memory usage reach a 1GB which resulted to hanging.
>
>I tried calling the dispose method of my form but it does not release the used memory either. Here is a sample code
>
>homeForm = new Form_Address1("Home Address);
>if (homeForm.ShowDialog(this) == DialogResult.OK)
>{
> homeForm.Dispose();
>}
>
>any idea?
>
>Thanks in advance...
Hector Correa
Previous
Reply
Map
View

Click here to load this message in the networking platform