Displaying forms in an array without closing each form


J

JW

Dear NG,

Still working on my .NET CF C# forms application ...

I have an array of forms that I wish to display in array order, and thus
have created a loop to run through them. Due to functional and speed
reasons (this app. will be deployed to a PocketPC) I want to merely Hide()
each form when the user is finished with it, rather than allow it to
Close(). In this way the user can "back" button their way back to each
previous form which has retained its state (functional), and each form is
only created once rather than a constant create/destroy demand on the
(small) processor (speed).

Problem: if I call ShowDialog() on each form I have to call Close() for each
form to return control to the array so that the next form can be displayed.
If I only call Show() the resulting form is not modal and so the array loop
goes on its merry way displaying the next (and the next, and the next etc.)
form.

At this point I am assuming that the solution will involve creating a new
thread in which to display each form, whilst the main thread waits to be
notified that it can continue? (because this is maybe how I would approach
the problem in Java?)

Is there some way to achieve this that I am missing or do I have to thread
my way out of this one?

Many TIAs,

James.
 
Ad

Advertisements

C

Cor Ligthert

JW,

In your message is something that triggers me. Constructing a form cost
time.
I think that is not true when you compare that with painting a form.

The constructing will normaly be a fraction from the painting in every
system.

That to let you think in another way before you create a memory consuming
solution on your pocket PC.

Cor
 
J

JW

Cor,

Many thanks for your reply.

Even if I factor in your comments about the cost of construction versus the
cost of repainting, isn't the cost of repainting incurred regardless of
whether or not I construct new forms all the time or reuse existing ones?
That is, any new form needs to be painted (made visible) for the first time
anyway?

James.
 
C

Cor Ligthert

JW,

When I look at your problem than I think that I would try to use a public
event on my forms and show and hide them according to that.

(They are all constructed of course so it will cost resources in my opinion)

Just an idea

Cor
 
J

JW

Dear NG,

I have solved the problem (for the moment?) by getting rid of the array loop
and passing control between each form in the sequence somewhat like a linked
list. In this way I can display each form as modeless, whilst retaining the
main thread of execution with the currently visible form.

James.
 
Ad

Advertisements

R

Rachel Suddeth

JW said:
Cor,

Many thanks for your reply.

Even if I factor in your comments about the cost of construction versus
the
cost of repainting, isn't the cost of repainting incurred regardless of
whether or not I construct new forms all the time or reuse existing ones?
That is, any new form needs to be painted (made visible) for the first
time
anyway?

James.
Yes, but I think the point is that if the time it takes to construct is, say
1/10 the time it takes to paint, which it has to do anyway, the user will
not notice the difference (most people can't tell the difference between .5
seconds and .55 seconds.) Also, these systems are limited in memory, and on
most computers, general performance slows down if you overload the memory. I
think the only way to really know if it's noticeably faster one way or the
other is to do testing both ways (under whatever is a normal load for that
machine.)

Of course, it may be that an application does something time-consuming when
it loads before the paint. Like, say, establishing a wireless network
connection. That might well take more time than either the rest of
construction or painting, and would be worthwhile to do once outside of
creating the forms if the memory used by keeping the entire form around was
an issue.
 
Ad

Advertisements


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

Top