When creating a form, a Dispose method gets automatically generated.
I notice that on the desktop this method gets called when the form closes.
With the CF the method is never called. Is this a fact or am I missing
something please?
Cheers
Daniel
The garbage collectors may work differently betwee the compact and desktop
frameworks. What exactly do you need to happen? For example, would explicitly
releasing a resource in a Closing event handler do what you need?
--
Ginny Caughey
Windows Embedded MVP
"Daniel Moth" <dmo...@hotmail.com> wrote in message
news:ezyefC21CHA.2912@TK2MSFTNGP10...
Its just a shame I have to code differently on the 2 platforms and I was
hoping that I was missing something...
Cheers
Daniel
"Ginny Caughey [MVP]" <ginny....@wasteworks.com> wrote in message
news:ujknjj21CHA.2216@TK2MSFTNGP09...
I understand what you're saying, but I think it's actually cleaner to do that on
the desktop too. ;-) In any case, since Microsoft monitors this newsgroup, I'm
sure they'll see your message.
--
Ginny Caughey
Windows Embedded MVP
"Daniel Moth" <dmo...@hotmail.com> wrote in message
news:Or$fZt21CHA.2372@TK2MSFTNGP09...
I am not sure its better since I have to add an extra method to my code
which apart from code bloat it results at runtime extra method call and
event handler... As unimportant as it is, I'd still be interested at reasons
why its cleaner though...
Hopefully MS will confirm the difference and put the philosophical
discussion to sleep :-)
Cheers
Daniel
"Ginny Caughey [MVP]" <ginny....@wasteworks.com> wrote in message
news:uw#vk421CHA.3096@TK2MSFTNGP10...
Its basically part of a pattern to release (unmanaged) resources in a
deterministic fashion (unlike Finalize which is not deterministic).
I suspect that on the full framework the forms/controls handler is
calling Dispose() in reponse to WM_CLOSE or WM_DESTROY (it is unlikely
that you are actually seeing GC at this point). The standard
implementation of Dispose() calls Dispose(true) (the significance of the
true is that you are not running in the finalizer thread and so you can
mess with managed objects too). If you are being called from the
finalizer you will be called with Dispose(false).
I would imagine that to save space CF does not do anything in response
to close/destroy.
Don't know if that helps
Simon
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
I don't disagree... It is as a result of WM_CLOSE that Dispose gets
called... V Small correction I believe the IDisposable interface is
implemented by Component from which Control derives (from which Form derives
as you pointed out :) Dispose(bool) is just an overload of Component (which
I guess explains your description of it as "unofficial part of IDisposable")
You are also probably right about CF leaving it out for spacesaving but
nevertheless I would like that to be acknowledged by MS and documented as a
difference from the desktop OR acknowledge it as a bug... whichever...
Cheers
Daniel
"Simon Wood" <anon...@devdex.com> wrote in message
news:e4C#uvA2CHA.1728@TK2MSFTNGP12...
"Daniel Moth" <dmo...@hotmail.com> wrote in message
news:#h2Z3BB2...@TK2MSFTNGP11.phx.gbl...
Cheers
"Erv Walter" <e...@ewal.net> wrote in message
news:eIEpmJE2CHA.1424@TK2MSFTNGP12...
I did a little browsing of the CF with ILDASM and I could not find any code
in Control or elsewhere that was disposing the objects in the Controls
container.
"Daniel Moth" <dmo...@hotmail.com> wrote in message
news:#jC4b8N2CHA.1760@TK2MSFTNGP12...
Turns out this is a bug - thank you everyone for bringing this to our
attention.
For .NetCF, once you close a form that was made visible via Visible = true
or Show(), it's dispose function should be called automatically. The
dispose function of it's child controls should also be called
automatically. We currently release the native handles, etc., but the
managed Dispose function doesn't get called (the bug). Note that
currently, if you try to do anything with the form after closing it, you'll
get an ObjectDisposedException because the native window has already been
destroyed.
Also, forms made visible via ShowDialog() are not automatically Disposed
when closed...you can reuse these forms. Their Dispose function should not
be called until the app exits in this case.
Hope this helps clear things up and thanks again for your posts.
-Katie
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
| From: "Daniel Moth" <dmo...@hotmail.com>
| References: <OI4vcJ$1CHA.2216@TK2MSFTNGP09>
<e4C#uvA2CHA.1728@TK2MSFTNGP12> <#h2Z3BB2...@TK2MSFTNGP11.phx.gbl>
<eIEpmJE2CHA.1424@TK2MSFTNGP12> <#jC4b8N2CHA.1760@TK2MSFTNGP12>
<ObZ4FcP2...@TK2MSFTNGP11.phx.gbl>
| Subject: Re: Form.Dispose
| Date: Thu, 20 Feb 2003 16:07:20 -0000
| Lines: 110
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2600.0000
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000
| Message-ID: <ebGH0pP2...@TK2MSFTNGP10.phx.gbl>
| Newsgroups: microsoft.public.dotnet.framework.compactframework
| NNTP-Posting-Host: 194.242.149.2
| Path: cpmsftngxa06!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP10.phx.gbl
| Xref: cpmsftngxa06
microsoft.public.dotnet.framework.compactframework:17205
| X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework