Click here to Skip to main content
15,891,695 members
Home / Discussions / C#
   

C#

 
QuestionHow reader information directory Pin
senalkan30-May-07 5:07
senalkan30-May-07 5:07 
AnswerRe: How reader information directory Pin
Manoj Kumar Rai30-May-07 5:34
professionalManoj Kumar Rai30-May-07 5:34 
AnswerRe: How reader information directory Pin
senalkan30-May-07 19:46
senalkan30-May-07 19:46 
GeneralRe: How reader information directory Pin
Manoj Kumar Rai30-May-07 21:21
professionalManoj Kumar Rai30-May-07 21:21 
GeneralRe: How reader information directory Pin
senalkan30-May-07 21:33
senalkan30-May-07 21:33 
QuestionDispose doubts Pin
Peterson Luiz30-May-07 4:21
Peterson Luiz30-May-07 4:21 
AnswerRe: Dispose doubts Pin
leppie30-May-07 4:47
leppie30-May-07 4:47 
AnswerRe: Dispose doubts Pin
Martin#30-May-07 5:06
Martin#30-May-07 5:06 
Hello,

Here is what I know (or think to know) about disposing.
peterson@brfree.com.br wrote:
Do I have to call dispose for every Windows Forms Controls in my UserControl's dispose?

No, If your UserControl is member of a parent which will be Disposed, it will automaticaly be called.
Lets say your UserControl is placed on an Windows.Form (So your Control is member of the ControlsCollection of the Form) and you call the Form.Close() method (which calls Dispose internal) you don't have to call Dispose of your Control.
If your Control is a member Variable which is removed from ControlsCollection during runtime , you will definitely have to Dispose your UserControl. But not the Controls which are Placed on the UserControl seperitaly (In fact, if they also are placed in the ControlsCollection of the UserControl).

peterson@brfree.com.br wrote:
I've been told to use System.Runtime.InteropServices.Marshal.ReleaseComObject() to free the resources of my COM object. Is that necessery?

Sorry, Don't have information about that.

peterson@brfree.com.br wrote:
I know that I shold dispose any bitmaps loaded. Does that means that I need to dispose an image of a picturebox, like picturebox1.image.dispose()? Or simply calling picturebox1.dispose() will do the job?

Same here, if your PictureBox is member of a ControlsCollection, you don't have to do so.
And you deffinitely don't have to dispose the "picturebox1.image".
But if you are changing the Image on runtime you will have to do so, before you add the new image.


peterson@brfree.com.br wrote:
What else do I need to dispose anyway? My userControl has a few arrays of strings, Colors and Images. I'm only disposing the images.

As string and Color are not IDisposable members you will not be able to dispose them.
You should think of calling dispose, allways if you instanciate something new, because there could be a old instance of some class which has no more reference to your class and is not disposed, whcih will cause a memory leak.

What's also very important apart from calling dispose, is what you are doing in your Dispose method of your UserControl.
for example the disconnection of delegate (eventhandler)

I'm using the .Net Memoryprofiler for the analysis of my project:http://memprofiler.com/[^]

Hope it helps!

All the best,

Martin
GeneralRe: Dispose doubts Pin
Peterson Luiz30-May-07 6:40
Peterson Luiz30-May-07 6:40 
AnswerRe: Dispose doubts Pin
Martin#30-May-07 8:46
Martin#30-May-07 8:46 
GeneralRe: Dispose doubts Pin
Peterson Luiz30-May-07 9:25
Peterson Luiz30-May-07 9:25 
AnswerRe: Dispose doubts Pin
Martin#30-May-07 10:17
Martin#30-May-07 10:17 
AnswerRe: Dispose doubts Pin
Jimmanuel30-May-07 6:30
Jimmanuel30-May-07 6:30 
Questionwant to make a folder sharable programatically Pin
devesh_code30-May-07 4:12
devesh_code30-May-07 4:12 
AnswerRe: want to make a folder sharable programatically Pin
Manoj Kumar Rai30-May-07 4:31
professionalManoj Kumar Rai30-May-07 4:31 
QuestionAdvice Pin
wwwlicious30-May-07 4:03
wwwlicious30-May-07 4:03 
AnswerRe: Advice [modified] Pin
Not Active30-May-07 4:12
mentorNot Active30-May-07 4:12 
GeneralRe: Advice Pin
wwwlicious30-May-07 4:32
wwwlicious30-May-07 4:32 
GeneralRe: Advice Pin
Manoj Kumar Rai30-May-07 4:48
professionalManoj Kumar Rai30-May-07 4:48 
QuestionRe: Advice Pin
wwwlicious30-May-07 5:03
wwwlicious30-May-07 5:03 
AnswerRe: Advice Pin
Manoj Kumar Rai30-May-07 5:19
professionalManoj Kumar Rai30-May-07 5:19 
GeneralRe: Advice Pin
wwwlicious30-May-07 6:00
wwwlicious30-May-07 6:00 
GeneralRe: Advice Pin
Not Active30-May-07 9:37
mentorNot Active30-May-07 9:37 
GeneralRe: Advice Pin
wwwlicious30-May-07 22:37
wwwlicious30-May-07 22:37 
GeneralRe: Advice Pin
Not Active31-May-07 2:06
mentorNot Active31-May-07 2:06 

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.