Dispose called twice

S

Sharon

Hi.
I put a message box in the form designer, Dispose method.
Clicking the form close (X) button, i noticed that the message,
appears twice.
My code does not call Dispose.
What is happening here?
Thanks.
Sharon.
 
K

Karl Seguin

Sharon:
This is an ASP.Net newsgroup, you might be better off asking in
microsoft.public.dotnet.framework.windowsforms

aside from that, I can tell you that Dipose must be implemented in such a
way that multiple calls to it aren't going to cause any problem, typically
this is achieved by using a private field named "isDisposed" or something
which is set to "false" and when Dispose() is called, something like this
happens:

if isDiposed = false then
..clean up resources
isDisposed = true
end if


therefore nothing bad can happen from it being called multiple times. I
figure it's doing so because a number of events are internally firing which
are each causing the Dispose method to be called...better to be safe than
sorry.

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/index.aspx - New and Improved (yes, the popup is
annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
 
S

Sharon

Thanks Karl for your reply.
This thread was opened by mistake, sorry.
It was meant for microsoft.public.dotnet.languages.csharp.
Anyway, what i want to know is the reason why dispose is called twice.
Regards.
Sharon.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,756
Messages
2,569,534
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top