473,396 Members | 1,847 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Does it make sense in FormClosed to do Me.Dispose

In the main program I check to see if a certain form has been disposed.

Does it make sense in that form's FormClosed event to do:
Me.Dispose to make sure it is disposed the next time I check.
Or is that automatic?
Thanks
Mar 13 '07
71 10653
Hii

For closing a form u can use

me.close();
OR
me.dispose();

or if u want to close the full application then also u can write this on
the parent form but that is not a good idea,
because due to that process's for that application will run. or we can
say that some internal processes u can see in task manager for that
application. So to avois that situation we can write End whereever
we want to close the application. This will end the whole process for
that application.

So here we go......

Nitin Sharma NXS

*** Sent via Developersdex http://www.developersdex.com ***
Mar 15 '07 #51

Hii

For closing a form u can use

me.close();
OR
me.dispose();

sometimes u can also use me.hide() for hiding that form.

or if u want to close the full application then also u can write this on
the parent form but that is not a good idea,
because due to that process's for that application will run. or we can
say that some internal processes u can see in task manager for that
application. So to avois that situation we can write End whereever
we want to close the application. This will end the whole process for
that application.

So here we go......

Nitin Sharma NXS

*** Sent via Developersdex http://www.developersdex.com ***
Mar 15 '07 #52
"If you don't know why something is, than use it. I probably does not hurt"

Cor, who said this? I've shown you that there are 3 general things
that dispose can do, and all in three situations calling Dispose
manually is better than letting the GC call it's Finalize and Dispose
methods. The only thing you argued is that the GC only runs in idle
time, on a separate thread - and you still haven't shown me the
documentation that proves this, so I'm starting to wonder if it
exists?

Thanks,

Seth Rowe
On Mar 15, 1:33 am, "Cor Ligthert [MVP]" <notmyfirstn...@planet.nl>
wrote:
Herfried,
I agee. Speaking more generally, interfaces are contracts. If a class
(or one of its derived classes, which one does not matter) implements
'IDisposable', this means "I cannot guarantee that I will never need
unmanaged resources". Even if the current implementation does not use
unmanaged resources, by implementing the interface it indicates that this
is not guaranteed.

But implementing IDisposable means direct that there is no need to call
dispose for all child members.
While we see that the sample implementation shows forever component in the
implementation.

However this combinantion gives direct the method dispose to every child and
a kind of foolish talking from people not knowing what to do on Internet
became populair.

"If you don't know why something is, than use it. I probably does not hurt"

Somebody who tells or write this in programming shows for me that he is an
absolute amateur.

Cor

Imagine even the case that another implementation of the
class than those contained in the .NET Framework may actually use
unmanaged resources and thus calling 'Dispose' makes perfect sense.
Unfortunately developers even nowadays spend a lot of time on
micro-optimizations which are often "unclean" hacks which will work on
their system, using a certain implementation, ..., but which are
counter-productive from the long-term perspective.
Besides if it wasn't needed, why would the parent call it's dispose
method from it's own dispose method?
Lastly, let me adapt Michael's question a little:
Can you show us some examples where manually calling Dispose is
detrimental to the application?
I don't think such an example exists (if the call is performed if the
object is not in use any more) because a method call is done quickly and
its better to do it sooner than later in order to prevent a resource
bottleneck.
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Mar 15 '07 #53
What you want me to do, proof that you are right in this discussion, I tell
all the time that dispose is only implemented in by instance label because
label is (somewhere in the base) inherited from Component. It is not ment to
use.
Cor, multiple people have shown you why it is important to Dispose of
labels, why are you still insisting that it is pointless? Are they
wrong about the window handles needing to be released?

Thanks,

Seth Rowe
On Mar 15, 2:15 am, "Cor Ligthert [MVP]" <notmyfirstn...@planet.nl>
wrote:
Michael,
I'm guessing by the fact that you didn't come up with another example that
you couldn't.

What you want me to do, proof that you are right in this discussion, I tell
all the time that dispose is only implemented in by instance label because
label is (somewhere in the base) inherited from Component. It is not ment to
use.

Almost the same is with the Text property in a picturebox. It does nothing,
it is there because Control has Text..

Cor

Mar 15 '07 #54
"Cor Ligthert [MVP]" <no************@planet.nlschrieb:
>I'm guessing by the fact that you didn't come up with another example
that you couldn't.
What you want me to do, proof that you are right in this discussion, I
tell all the time that dispose is only implemented in by instance label
because label is (somewhere in the base) inherited from Component. It is
not ment to use.
If you are talking about 'System.Windows.Forms.Label', 'Dispose' does a lot
of work. It's not only implemented in the base class but also the 'Control'
class and overridden in the 'Label' class. Calling 'Dispose' will release
some objects associated with the control and delete the Win32 control.
Almost the same is with the Text property in a picturebox. It does
nothing, it is there because Control has Text..
That's IMO something different, as your sample with the 'ToString' method
is. The 'Text' property doesn't fit semantically and the 'ToString'
property is only used for a special purpose. It doesn't make sense to use
it in places in which you do not want a string representation of the object.
'Dispose' simply signals that the class may hold resources until
finalization which can be released at an earlier point.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Mar 15 '07 #55
Multiple means here 2. Far more people have showed me that it is without
sense.

"rowe_newsgroups" <ro********@yahoo.comschreef in bericht
news:11**********************@n76g2000hsh.googlegr oups.com...
>What you want me to do, proof that you are right in this discussion, I
tell
all the time that dispose is only implemented in by instance label
because
label is (somewhere in the base) inherited from Component. It is not ment
to
use.

Cor, multiple people have shown you why it is important to Dispose of
labels, why are you still insisting that it is pointless? Are they
wrong about the window handles needing to be released?

Thanks,

Seth Rowe
On Mar 15, 2:15 am, "Cor Ligthert [MVP]" <notmyfirstn...@planet.nl>
wrote:
>Michael,
I'm guessing by the fact that you didn't come up with another example
that
you couldn't.

What you want me to do, proof that you are right in this discussion, I
tell
all the time that dispose is only implemented in by instance label
because
label is (somewhere in the base) inherited from Component. It is not ment
to
use.

Almost the same is with the Text property in a picturebox. It does
nothing,
it is there because Control has Text..

Cor


Mar 15 '07 #56
Tom,

The dispose can be used to do overriden actions.

AdoNet has used it in past to remove the physical connection string.

(A question do you still see samples with Dispose on MSDN, while that was in
past often done?)

Cor

"Tom Shelton" <to*********@comcast.netschreef in bericht
news:11**********************@n59g2000hsh.googlegr oups.com...
On Mar 15, 12:15 am, "Cor Ligthert [MVP]" <notmyfirstn...@planet.nl>
wrote:
>Michael,
I'm guessing by the fact that you didn't come up with another example
that
you couldn't.

What you want me to do, proof that you are right in this discussion, I
tell
all the time that dispose is only implemented in by instance label
because
label is (somewhere in the base) inherited from Component. It is not ment
to
use.

Almost the same is with the Text property in a picturebox. It does
nothing,
it is there because Control has Text..

Cor

Cor - labels .Dispose most definately does something. I suggest you
get out Reflector and follow the chain.... HINT: It eventually
releases the window handle (a finite unmanaged system resource).

--
Tom Shelton

Mar 15 '07 #57
Seth,

Open the hidden part of your windows form program. There you see the
implementation of IDisposable with the component. That does all disposing
for you including labels. This with the exception of the Dialogforms.

Cor

"rowe_newsgroups" <ro********@yahoo.comschreef in bericht
news:11**********************@n76g2000hsh.googlegr oups.com...
>What you want me to do, proof that you are right in this discussion, I
tell
all the time that dispose is only implemented in by instance label
because
label is (somewhere in the base) inherited from Component. It is not ment
to
use.

Cor, multiple people have shown you why it is important to Dispose of
labels, why are you still insisting that it is pointless? Are they
wrong about the window handles needing to be released?

Thanks,

Seth Rowe
On Mar 15, 2:15 am, "Cor Ligthert [MVP]" <notmyfirstn...@planet.nl>
wrote:
>Michael,
I'm guessing by the fact that you didn't come up with another example
that
you couldn't.

What you want me to do, proof that you are right in this discussion, I
tell
all the time that dispose is only implemented in by instance label
because
label is (somewhere in the base) inherited from Component. It is not ment
to
use.

Almost the same is with the Text property in a picturebox. It does
nothing,
it is there because Control has Text..

Cor


Mar 15 '07 #58
Because it takes some time.
" active" <ac**********@a-znet.comschreef in bericht
news:%2****************@TK2MSFTNGP02.phx.gbl...
but why does this work
OpenFileDialog1.ShowDialog()
after it has been disposed

"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:up**************@TK2MSFTNGP04.phx.gbl...
>active,

The GC runs on a seperated thread.

Cor

" active" <ac**********@a-znet.comschreef in bericht
news:uz**************@TK2MSFTNGP06.phx.gbl...
>>Can someone explain this test result?

It shows the open dialog twice.

After the Dispose I wouldn't expect the box was still useful

Unless the Dispose does nothing

If so why have it?

Anyone know what is going on here?

GC.Collect()

OpenFileDialog1.ShowDialog()

OpenFileDialog1.Dispose()

GC.Collect()

OpenFileDialog1.ShowDialog()



Mar 15 '07 #59
Open the hidden part of your windows form program. There you see the
implementation of IDisposable with the component. That does all disposing
for you including labels. This with the exception of the Dialogforms.
Yes Cor, I know that - as a matter of fact I mentioned previously in
this thread that the many parent objects dispose it's children in it's
own dispose method. Besides, I thought we were talking about disposing
of dynamically created and removed labels? As those are the only ones
we need to worry about disposing since the generated code will remove
the ones in the control collection.

Also, if removing Labels is pointless and stupid as you have alluded
to, have you written Microsoft to tell them that the generated code is
wrong in disposing of labels and other objects that inherit from
component?

Thanks,

Seth Rowe
On Mar 15, 8:12 am, "Cor Ligthert [MVP]" <notmyfirstn...@planet.nl>
wrote:
Seth,

Open the hidden part of your windows form program. There you see the
implementation of IDisposable with the component. That does all disposing
for you including labels. This with the exception of the Dialogforms.

Cor

"rowe_newsgroups" <rowe_em...@yahoo.comschreef in berichtnews:11**********************@n76g2000hsh.g ooglegroups.com...
What you want me to do, proof that you are right in this discussion, I
tell
all the time that dispose is only implemented in by instance label
because
label is (somewhere in the base) inherited from Component. It is not ment
to
use.
Cor, multiple people have shown you why it is important to Dispose of
labels, why are you still insisting that it is pointless? Are they
wrong about the window handles needing to be released?
Thanks,
Seth Rowe
On Mar 15, 2:15 am, "Cor Ligthert [MVP]" <notmyfirstn...@planet.nl>
wrote:
Michael,
I'm guessing by the fact that you didn't come up with another example
that
you couldn't.
What you want me to do, proof that you are right in this discussion, I
tell
all the time that dispose is only implemented in by instance label
because
label is (somewhere in the base) inherited from Component. It is not ment
to
use.
Almost the same is with the Text property in a picturebox. It does
nothing,
it is there because Control has Text..
Cor

Mar 15 '07 #60
Multiple means here 2.

So you're admitting that 2 people have shown you that it makes sense?
Far more people have showed me that it is without sense.
Ok, who might they be and what were their arguments that it is
senseless?

Thanks,

Seth Rowe
On Mar 15, 8:05 am, "Cor Ligthert [MVP]" <notmyfirstn...@planet.nl>
wrote:
Multiple means here 2. Far more people have showed me that it is without
sense.

"rowe_newsgroups" <rowe_em...@yahoo.comschreef in berichtnews:11**********************@n76g2000hsh.g ooglegroups.com...
What you want me to do, proof that you are right in this discussion, I
tell
all the time that dispose is only implemented in by instance label
because
label is (somewhere in the base) inherited from Component. It is not ment
to
use.
Cor, multiple people have shown you why it is important to Dispose of
labels, why are you still insisting that it is pointless? Are they
wrong about the window handles needing to be released?
Thanks,
Seth Rowe
On Mar 15, 2:15 am, "Cor Ligthert [MVP]" <notmyfirstn...@planet.nl>
wrote:
Michael,
I'm guessing by the fact that you didn't come up with another example
that
you couldn't.
What you want me to do, proof that you are right in this discussion, I
tell
all the time that dispose is only implemented in by instance label
because
label is (somewhere in the base) inherited from Component. It is not ment
to
use.
Almost the same is with the Text property in a picturebox. It does
nothing,
it is there because Control has Text..
Cor

Mar 15 '07 #61
On Mar 15, 1:09 am, "Michael C" <nos...@nospam.comwrote:
"Tom Shelton" <tom_shel...@comcast.netwrote in message

news:11**********************@b75g2000hsg.googlegr oups.com...
I hope you can ignore the partial response... I accidently hit
send :) Anyway, the point of that oh, so obnoxious C# code was that I
believe with forms/usercontrols/etc - you should probably call dispose
(especiall if they are dynamically created/removed).

From what I can tell you only need to do it if they a dynamically created
for controls.
Yes - I went a little to far. For instance, you don't need to call
dispose on controls sited on a form - because when the form is
disposed it will dispose the children. Really, the only things you
need to worry about are controls that are being removed from the form
in a dynamic fashion or dialog forms...

--
Tom Shelton

Mar 15 '07 #62
So immediately after I do a dispose I might still be able to access the
object. That's a surprise.

I understand that the GC may not happen for some time but it's anybody guess
what dispose may have done to the object.

Just to refresh, the original question was why does the second
OpenFileDialog work after the object has been disposed. The GC lines were
only there because I did cut - paste.
>>>GC.Collect()
OpenFileDialog1.ShowDialog()

OpenFileDialog1.Dispose()

GC.Collect()

OpenFileDialog1.ShowDialog()

Thanks, as always, for replying

"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:e%***************@TK2MSFTNGP02.phx.gbl...
Because it takes some time.
" active" <ac**********@a-znet.comschreef in bericht
news:%2****************@TK2MSFTNGP02.phx.gbl...
>but why does this work
OpenFileDialog1.ShowDialog()
after it has been disposed

"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:up**************@TK2MSFTNGP04.phx.gbl...
>>active,

The GC runs on a seperated thread.

Cor

" active" <ac**********@a-znet.comschreef in bericht
news:uz**************@TK2MSFTNGP06.phx.gbl...
Can someone explain this test result?

It shows the open dialog twice.

After the Dispose I wouldn't expect the box was still useful

Unless the Dispose does nothing

If so why have it?

Anyone know what is going on here?

GC.Collect()

OpenFileDialog1.ShowDialog()

OpenFileDialog1.Dispose()

GC.Collect()

OpenFileDialog1.ShowDialog()





Mar 15 '07 #63
" active" <ac**********@a-znet.comschrieb:
So immediately after I do a dispose I might still be able to access the
object. That's a surprise.

I understand that the GC may not happen for some time but it's anybody
guess what dispose may have done to the object.

Just to refresh, the original question was why does the second
OpenFileDialog work after the object has been disposed. The GC lines were
only there because I did cut - paste.
'OpenFileDialog' inherits 'Dispose' from its 'Component' base type but does
not override it. The implementation in 'Component' looks as follows
(according to Reflector):

\\\
Protected Overridable Sub Dispose(ByVal disposing As Boolean)
If disposing Then
SyncLock Me
If _
( _
(Not Me.site Is Nothing) AndAlso _
(Not Me.site.Container Is Nothing) _
) _
Then
Me.site.Container.Remove(Me)
End If
If (Not Me.events Is Nothing) Then
Dim handler1 As EventHandler = _
DirectCast( _
Me.events.Item(Component.EventDisposed), _
EventHandler _
)
If (Not handler1 Is Nothing) Then
handler1.Invoke(Me, EventArgs.Empty)
End If
End If
End SyncLock
End If
End Sub
///

.... which does not prevent the dialog from working. It only disconnects it
from its container.

However, I recommend to call 'Dispose' here too because an implementation on
another operating system than Windows may add custom disposing code.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Mar 15 '07 #64

"Herfried K. Wagner [MVP]" <hi***************@gmx.atwrote in message
news:Om**************@TK2MSFTNGP03.phx.gbl...
>" active" <ac**********@a-znet.comschrieb:
>So immediately after I do a dispose I might still be able to access the
object. That's a surprise.

I understand that the GC may not happen for some time but it's anybody
guess what dispose may have done to the object.

Just to refresh, the original question was why does the second
OpenFileDialog work after the object has been disposed. The GC lines were
only there because I did cut - paste.

'OpenFileDialog' inherits 'Dispose' from its 'Component' base type but
does not override it. The implementation in 'Component' looks as follows
(according to Reflector):

\\\
Protected Overridable Sub Dispose(ByVal disposing As Boolean)
If disposing Then
SyncLock Me
If _
( _
(Not Me.site Is Nothing) AndAlso _
(Not Me.site.Container Is Nothing) _
) _
Then
Me.site.Container.Remove(Me)
End If
If (Not Me.events Is Nothing) Then
Dim handler1 As EventHandler = _
DirectCast( _
Me.events.Item(Component.EventDisposed), _
EventHandler _
)
If (Not handler1 Is Nothing) Then
handler1.Invoke(Me, EventArgs.Empty)
End If
End If
End SyncLock
End If
End Sub
///

... which does not prevent the dialog from working. It only disconnects
it from its container.

However, I recommend to call 'Dispose' here too because an implementation
on another operating system than Windows may add custom disposing code.

I'm guess that I should only dispose if it is not added by the Designer,
right?

And if I do dispose I don't do it until the last usage, right?
Thanks a lot

>
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Mar 15 '07 #65
"rowe_newsgroups" <ro********@yahoo.comwrote in message
Cor, multiple people have shown you why it is important to Dispose of
labels, why are you still insisting that it is pointless? Are they
wrong about the window handles needing to be released?
Cor just doesn't want to admit he is wrong. You need to call dispose, this
is very well known and not in dispute.

Michael
Mar 18 '07 #66
Michael,

Try this and give than a honest answer.
You said a label has to be disposed.

This sample I made for the question Override.

I expect that I get an answer that I don't understand it and my English is
not good enough, be aware however I am not the only reader in this
newsgroup.

\\\
Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Dim myLabel As New MyBaseLabel
Me.Controls.Add(myLabel)
End Sub
////
Just add this class under the end class of the form
\\\\
Public Class MyBaseLabel
Inherits System.Windows.Forms.TextBox
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
MessageBox.Show("The label is disposing")
End If
MyBase.Dispose(disposing)
End Sub
End Class
///
"Michael C" <no****@nospam.comschreef in bericht
news:e6**************@TK2MSFTNGP02.phx.gbl...
"rowe_newsgroups" <ro********@yahoo.comwrote in message
>Cor, multiple people have shown you why it is important to Dispose of
labels, why are you still insisting that it is pointless? Are they
wrong about the window handles needing to be released?

Cor just doesn't want to admit he is wrong. You need to call dispose, this
is very well known and not in dispute.

Michael

Mar 18 '07 #67
"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:u0**************@TK2MSFTNGP04.phx.gbl...
Michael,

Try this and give than a honest answer.
You said a label has to be disposed.

This sample I made for the question Override.

I expect that I get an answer that I don't understand it and my English is
not good enough, be aware however I am not the only reader in this
newsgroup.
Maybe I misunderstood what you're trying to say. Any object that has a
Dispose method should have Dispose called. However, in the case of labels
Dispose is called for you, so you don't need to explicitly call it yourself.
If you remove the label from the form manually then I believe you need to
call dispose because it will not be done for you.

Michael
Mar 18 '07 #68
On Mar 18, 6:28 pm, "Cor Ligthert [MVP]" <notmyfirstn...@planet.nl>
wrote:
Michael,

Try this and give than a honest answer.
You said a label has to be disposed.

This sample I made for the question Override.

I expect that I get an answer that I don't understand it and my English is
not good enough, be aware however I am not the only reader in this
newsgroup.

\\\
Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Dim myLabel As New MyBaseLabel
Me.Controls.Add(myLabel)
End Sub
////
Just add this class under the end class of the form
\\\\
Public Class MyBaseLabel
Inherits System.Windows.Forms.TextBox
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
MessageBox.Show("The label is disposing")
End If
MyBase.Dispose(disposing)
End Sub
End Class
///

"Michael C" <nos...@nospam.comschreef in berichtnews:e6**************@TK2MSFTNGP02.phx.gbl. ..
"rowe_newsgroups" <rowe_em...@yahoo.comwrote in message
Cor, multiple people have shown you why it is important to Dispose of
labels, why are you still insisting that it is pointless? Are they
wrong about the window handles needing to be released?
Cor just doesn't want to admit he is wrong. You need to call dispose, this
is very well known and not in dispute.
Michael
Cor, we've already talked about this behavior and stated that it
wasn't what we were talking about. We know that the form disposes of
the objects in it's controls collection automatically, we were talking
about the need to dispose of dynamically removed controls (or one's
that aren't present in the control collection of a parent object)

Besides, doesn't your example show that it is a good practice to
dispose of the label as the function is present by design? After all
if the designers (who probably know the inner working of the controls)
dispose of these controls when they remove them, shouldn't we do the
same?

Thanks,

Seth Rowe

Mar 19 '07 #69
Cor,

"Cor Ligthert [MVP]" <no************@planet.nlschrieb:
\\\\
Public Class MyBaseLabel
Inherits System.Windows.Forms.TextBox
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
MessageBox.Show("The label is disposing")
End If
MyBase.Dispose(disposing)
End Sub
End Class
///
Be aware that messageboxes shown from the 'Dispose' method are not always
shown although the lines are executed. It's more secure to set a breakpoint
or use a 'Stop' statement for debugging purposes.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Mar 19 '07 #70
Herfried,

Do you really think that I will use this kind of programming, it is only to
show that forms implements Idisposable and therefore that what is placed on
it will be disposed without manual handling from the programmer. That I have
written in this thread, but is consequently denied.

Some of the messages written not by me.
>Cor just doesn't want to admit he is wrong. You need to call dispose, this
is very well known and not in dispute.
Cor, multiple people have shown you why it is important to Dispose of
labels, why are you still insisting that it is pointless?
The point is that these programmers know when they don't need to know,
which is the whole point of IDisposable. You don't need to know it uses
unmanaged resources or not, all you need to know is that you should
dispose an object once finished with it *if* it has IDisposable interface.
Cor

"Herfried K. Wagner [MVP]" <hi***************@gmx.atschreef in bericht
news:eA**************@TK2MSFTNGP04.phx.gbl...
Cor,

"Cor Ligthert [MVP]" <no************@planet.nlschrieb:
>\\\\
Public Class MyBaseLabel
Inherits System.Windows.Forms.TextBox
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
MessageBox.Show("The label is disposing")
End If
MyBase.Dispose(disposing)
End Sub
End Class
///

Be aware that messageboxes shown from the 'Dispose' method are not always
shown although the lines are executed. It's more secure to set a
breakpoint or use a 'Stop' statement for debugging purposes.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Mar 19 '07 #71
Do you really think that I will use this kind of programming, it is only to
show that forms implements Idisposable and therefore that what is placed on
it will be disposed without manual handling from the programmer. That I have
written in this thread, but is consequently denied.
As far as I can tell, no one is denying that forms dispose of their
child controls? As a matter of fact I have stated this 3 times in this
thread!

Again, we are talking about the need to dispose of controls that we
remove from a form before the form is disposed.

i.e.

' Typed in message

private sub Foo()
Dim myLabel as new Label()
myForm.Controls.Add(myLabel)
myForm.Controls.Remove(myLabel)
myLabel.Dispose()
end sub

So do you understand what we are talking about now?

Thanks,

Seth Rowe
On Mar 19, 2:37 am, "Cor Ligthert [MVP]" <notmyfirstn...@planet.nl>
wrote:
Herfried,

Do you really think that I will use this kind of programming, it is only to
show that forms implements Idisposable and therefore that what is placed on
it will be disposed without manual handling from the programmer. That I have
written in this thread, but is consequently denied.

Some of the messages written not by me.
Cor just doesn't want to admit he is wrong. You need to call dispose, this
is very well known and not in dispute.
Cor, multiple people have shown you why it is important to Dispose of
labels, why are you still insisting that it is pointless?
The point is that these programmers know when they don't need to know,
which is the whole point of IDisposable. You don't need to know it uses
unmanaged resources or not, all you need to know is that you should
dispose an object once finished with it *if* it has IDisposable interface.

Cor

"Herfried K. Wagner [MVP]" <hirf-spam-me-h...@gmx.atschreef in berichtnews:eA**************@TK2MSFTNGP04.phx.gbl. ..
Cor,
"Cor Ligthert [MVP]" <notmyfirstn...@planet.nlschrieb:
\\\\
Public Class MyBaseLabel
Inherits System.Windows.Forms.TextBox
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
MessageBox.Show("The label is disposing")
End If
MyBase.Dispose(disposing)
End Sub
End Class
///
Be aware that messageboxes shown from the 'Dispose' method are not always
shown although the lines are executed. It's more secure to set a
breakpoint or use a 'Stop' statement for debugging purposes.
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Mar 19 '07 #72

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: John Edwards | last post by:
Hello, I have sort of a newbie question. I'm trying to optimize a loop by breaking it into two passes. Example: for(i = 0; i < max; i++) {
0
by: milkyway | last post by:
Hello, I am trying to find an old post I had but here goes another :-) I am trying to make an application that will work under WML and from the regular computer. >From what I have read, one...
1
by: | last post by:
I have a inquiry form that works perfectly under nearly every condition I test. Yet, I seem to be getting increasing error messages from users and I cannot figure out the cuase of the problem:...
0
by: mike | last post by:
regards: Does the following programming architecture make sense? http://www.wretch.cc/album/show.php?i=otp&b=1&f=1111993473&p=2 ...
10
by: DataBard007 | last post by:
Hello Access Gurus: I use Win98SE and Access97. I just built a simple Access97 application which holds all contact information for my personal contacts, such as first name, last name, address,...
2
by: mikelinyoho | last post by:
Does the following program architecture make sense? #include <stdio.h> #include "test1.c" #include "sample.cpp" int main(void){ output();
1
by: mikeotp | last post by:
Does the statement make sense? Meaning of “program” is to setup *.h(header檔) and to edit a main file to be a program exit. The main file includes all of the“*.h” files I edited before....
2
by: dougloj | last post by:
Hi. I have an ASP.NET application written in C#. To log in, a user must provide their email address and password. I already give the user a "Remember my Email Address" check box. If they check...
2
by: puzzlecracker | last post by:
I have never seen this in practice and interested in its pros, or ever existential (another words, standardized) possibility? Thanks, Sasha
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.