Click here to Skip to main content
15,894,271 members
Home / Discussions / C#
   

C#

 
QuestionDispose groupbox Pin
Ronny Portier15-Apr-12 3:06
Ronny Portier15-Apr-12 3:06 
AnswerRe: Dispose groupbox Pin
Luc Pattyn15-Apr-12 3:15
sitebuilderLuc Pattyn15-Apr-12 3:15 
GeneralRe: Dispose groupbox Pin
Ronny Portier15-Apr-12 5:21
Ronny Portier15-Apr-12 5:21 
AnswerRe: Dispose groupbox Pin
Luc Pattyn15-Apr-12 5:44
sitebuilderLuc Pattyn15-Apr-12 5:44 
GeneralRe: Dispose groupbox Pin
phil.o15-Apr-12 5:32
professionalphil.o15-Apr-12 5:32 
AnswerRe: Dispose groupbox Pin
DaveyM6915-Apr-12 5:49
professionalDaveyM6915-Apr-12 5:49 
AnswerRe: Dispose groupbox Pin
Abhinav S15-Apr-12 6:05
Abhinav S15-Apr-12 6:05 
AnswerRe: Dispose groupbox Pin
Luc Pattyn15-Apr-12 6:18
sitebuilderLuc Pattyn15-Apr-12 6:18 
I disagree. Of course the GC will eventually clean up whatever isn't needed any more, once new objects are needed and it has ran out of memory. However objects that hold big or expensive or unmanaged resources should provide a Dispose() method and that method should be called explicitly as soon as possible. If anything, it will make your app lighter and more responsive.

BTW: I checked using Reflector, and found this snippet burried deep inside Control.Dispose():
ControlCollection controls = (ControlCollection) this.Properties.GetObject(PropControlsCollection);
if (controls != null)
{
    for (int i = 0; i < controls.Count; i++)
    {
        Control control = controls[i];
        control.parent = null;
        control.Dispose();
    }
    this.Properties.SetObject(PropControlsCollection, null);
}
base.Dispose(disposing);


If MS finds it necessary to dispose of Controls, why shouldn't you?

Smile | :)
Luc Pattyn [My Articles] Nil Volentibus Arduum

AnswerRe: Dispose groupbox Pin
Abhinav S15-Apr-12 6:51
Abhinav S15-Apr-12 6:51 
AnswerRe: Dispose groupbox Pin
Luc Pattyn15-Apr-12 6:58
sitebuilderLuc Pattyn15-Apr-12 6:58 
GeneralRe: Dispose groupbox Pin
Abhinav S15-Apr-12 7:23
Abhinav S15-Apr-12 7:23 
AnswerRe: Dispose groupbox Pin
V.15-Apr-12 21:56
professionalV.15-Apr-12 21:56 
AnswerRe: Dispose groupbox Pin
Pete O'Hanlon15-Apr-12 23:45
mvePete O'Hanlon15-Apr-12 23:45 
Questionproblem in restoring mysql database Pin
altafmohd14-Apr-12 21:35
altafmohd14-Apr-12 21:35 
AnswerRe: problem in restoring mysql database Pin
OriginalGriff14-Apr-12 22:30
mveOriginalGriff14-Apr-12 22:30 
GeneralRe: problem in restoring mysql database Pin
altafmohd14-Apr-12 22:41
altafmohd14-Apr-12 22:41 
QuestionRe: problem in restoring mysql database Pin
Eddy Vluggen15-Apr-12 0:35
professionalEddy Vluggen15-Apr-12 0:35 
AnswerRe: problem in restoring mysql database Pin
altafmohd15-Apr-12 0:46
altafmohd15-Apr-12 0:46 
GeneralRe: problem in restoring mysql database Pin
Eddy Vluggen15-Apr-12 1:03
professionalEddy Vluggen15-Apr-12 1:03 
GeneralRe: problem in restoring mysql database Pin
altafmohd15-Apr-12 1:19
altafmohd15-Apr-12 1:19 
AnswerRe: problem in restoring mysql database Pin
Eddy Vluggen15-Apr-12 1:27
professionalEddy Vluggen15-Apr-12 1:27 
AnswerRe: problem in restoring mysql database Pin
Luc Pattyn15-Apr-12 3:19
sitebuilderLuc Pattyn15-Apr-12 3:19 
GeneralRe: problem in restoring mysql database Pin
altafmohd15-Apr-12 5:04
altafmohd15-Apr-12 5:04 
AnswerRe: problem in restoring mysql database Pin
Bernhard Hiller15-Apr-12 21:18
Bernhard Hiller15-Apr-12 21:18 
QuestionHow well do you know your TryParse()? Pin
Ravi Bhavnani14-Apr-12 10:11
professionalRavi Bhavnani14-Apr-12 10:11 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.