Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to develop applications with multiple Forms?

0 views
Skip to first unread message

Manfred Denzer

unread,
Oct 23, 2008, 9:41:13 AM10/23/08
to
Hello developers!

I develop with C# and the .NET Compact Framework for Windows Mobile in
Microsoft Visual Studio 2005.
I'm very confused at the moment... I developed an application with
more than 30 forms (System.Windows.Forms.Form). Depending on what
button the user clicks, the next form will be loaded.

This is my structure: All forms inherit from a superclass, which
provides a full screen background image und some buttons needed on
every form. I develop a form-cache to save all forms when it is opened
the first time. If a form is needed a second time, the form opens very
quickly.

If I open a lot of forms, i get an OutOfMemoryException. So I look in
Windows Mobile in "Windows -> Settings -> System -> Memory". Oh, my
application needs over 25 MB RAM. Then, I clicked on "Running
Programs" and get frightened: The list is full with all my forms:
Form1, Form2, Form3, Form4, ...

Now, I think that I managed my forms wrong right from the start of
development, isn't it?
Is it better to have only ONE form and chance the controls on it?
Or is it ok to have multiple form? But it is not good to have a lot of
entries on "Running Programs", or?

Thank you very much for your help!
Manfred Denzer

Chris Tacke, eMVP

unread,
Oct 23, 2008, 11:27:10 AM10/23/08
to
Running Programs simply lists the text in all top-level Forms. Set the text
of any given Form to an empty string and it won't show up.

The memory issue is becasue you have 30 Form is memory, along with all if
their referenced classes. You'll have to pitch data at some point. A
reasonable mechanism is to wrap calls in exception handlers and when you get
an OOM, pop some of the oldest forms from your cache. Another option is to
only cache frequently used Forms.

Using 1 form with lots of controls isn't going to buy you anything and would
be a nightmare to maintain.


--

Chris Tacke, Embedded MVP
OpenNETCF Consulting
Giving back to the embedded community
http://community.OpenNETCF.com

"Manfred Denzer" <el.fl...@googlemail.com> wrote in message
news:1bb0328b-0d38-4bd3...@d45g2000hsc.googlegroups.com...

Manfred Denzer

unread,
Oct 24, 2008, 2:56:57 AM10/24/08
to
Thank you very much for your detailed answer :-)
I'm happy, that I not have to redevelop my application.
I will catch the OOM and remove Forms from my cache!
Greetings
Manfred

Simon Hart [MVP]

unread,
Oct 26, 2008, 1:56:49 PM10/26/08
to
To get around the multiple forms showing under task manager, see if this
linke helps:
http://www.simonrhart.com/2008/03/systemwindowsformsformowner.html

--
Simon Hart
Visual Developer - Device Application Development MVP
http://www.simonrhart.com

"Manfred Denzer" <el.fl...@googlemail.com> wrote in message
news:1bb0328b-0d38-4bd3...@d45g2000hsc.googlegroups.com...

0 new messages