Dynamic Controls - Performance

G

Guest

Hi,

I have a question about creating multiple controls in my .net CF app.

The main section of the client works by dynamically creating controls onto a
Dialog panel, as specified in a pre-defined config file which determines the
layout for each screen. When a new screen is requested, the current controls
on the panel are disposed and then the new screen layout objects are loaded
and turned into controls and displayed on top of our Panel. This works well
for a period of time, but as usage continues begins to slow down until it
takes a few seconds to show each new screen. At the moment I am
investigating whether this is caused by the redrawing process, as the
background functionality does not appear to be slowing significantly. This
dialog is maintained throughout the life of the app.

Does anyone have any ideas as to why this may be, or if you require further
info then please just let me know.

Thanks!
 
C

Christian Schwarz

The main section of the client works by dynamically creating controls onto
a
Dialog panel, as specified in a pre-defined config file which determines
the
layout for each screen. When a new screen is requested, the current
controls
on the panel are disposed and then the new screen layout objects are
loaded
and turned into controls and displayed on top of our Panel. This works
well
for a period of time, but as usage continues begins to slow down until it
takes a few seconds to show each new screen. At the moment I am
investigating whether this is caused by the redrawing process, as the
background functionality does not appear to be slowing significantly.
This
dialog is maintained throughout the life of the app.

We're using a very similar approach in one of our projects and noticed the
same problem. The difference to your method is that all controls are reused
to speed up the whole thing. Profiling revealed that the
process of adding the controls to the dialog (control.Parent = myDialog;) is
the killer. This process quickly slows down up to several seconds for 2
TextBox and 2 Label controls. So far, the reason isn't clear to me.

So I'm very interrested in finding a solution for this issue, too.

Christian
 
G

Guest

Christian,

I have managed to get the controls displaying properly now, and it appears
that the performance is no longer an issue. The changes I made to the
process below were to use a bank of member variable Controls which belonged
to my dialog class, and allocate the new textbox, listbox, button etc to the
next available one of these Controls variables.

I then add this variable to a hashtable using the control's label in order
to index it. The Control is then added to a panel which sits on the dialog.

When I want to display the next dynamic screen, I dispose of each control
that has been used, then dispose of the Panel. I then re-create and
initialise the panel to how it was and add then re-allocate the controls of
the new screen into my member variable controls.

As i say, at present this seems to be keeping the performance up without it
picking up a delay over time.

Hope this helps in some way!!

Cheers,

Stuart
 

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