Slow Display of Forms

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,
Reg: Pocket PC-Vb.net
I have to display another form, while clicking on a button. Before
displaying the form, 3 text files(contain around 500 records each) have to be
read and based on the contents, I have to populate the textboxes in the form.

When I am clicking the button, the form is displayed very slowly, since it
take some time to read the text files. I have written the code in the click
event of the button. I am using a class to read those files. Is there any
way to avoid this delay?

Before displaying the form, I have to check the existance of text files
also.(using file.exits())

Awaiting your valuable suggestions,

Regards,
Hari
 
Hari,

the first thing you should do it display a progress meter of what's going on
while the text files are being read, this will give the user some indication
that they're waiting for a reason. An app that just "hungs" for a 10 or 15
seconds looks as though the app has crashed when it may be something in the
background slowing it up. But if you've a progress bar with a "please wait
while this file loads" type message, the user would prepare to wait twice as
long with no worry because something "appears" to be happening.

Second, do you need all the data at once? By this I mean, would it be better
to browse one file at a time, or extract data as you need it...

Finally, the other option is to look at seperate instances in the
application when the data could be loaded, one idea would be the splash
screen for example.

Thanks.

Dan.
 
Hari,

To add to Dan's last suggestion, why not instantiate the form that requires
those three text files on a separate thread, in advance of actually showing
the form? And once you have done this, cache the form so that you never
incur the expense of loading all that data again. The simplest way to cache
a form is to use the singleton pattern which allows other forms on the main
execution thread to simply get the instance of the form and show it.

-Darren
 
Dear Dan,

Thank You. Since I wish to populate the form with the data from all the 3
text files, I have to read all text files one by one. So I wish to make use
of your third suggestion.

Hari
 
Dear Darren,

Thank You. Your suggestion is excellent and I can understand the concept
very well. But I am not so familiar with multithreaded programming.

So from your tips, I will do some search and study the topic and implement it.

Once again my sincere thanks,

Regards,
Hari
 
One other tip Hari - caching a form by making it a singleton and
instantiating only once is quick to implement and gets the job done
without multi-threading. For a solution that has the ability to pre-cache a
form on a separate thread, Chris Tacke has written an excellent
article describing a pattern he names the FormStack which I highly
recommend. You can read about it here:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetcomp/html/casoast.asp

- Darren Shaffer
 
Thank you very much, Darren

Darren Shaffer said:
One other tip Hari - caching a form by making it a singleton and
instantiating only once is quick to implement and gets the job done
without multi-threading. For a solution that has the ability to pre-cache a
form on a separate thread, Chris Tacke has written an excellent
article describing a pattern he names the FormStack which I highly
recommend. You can read about it here:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetcomp/html/casoast.asp

- Darren Shaffer
 
Darren,

when a button is clicked, the form is displayed. Before displaying the
form, I am hiding the form and reading the text files, and in the form load
event of the new form, i am making it visible.

It is only taking one second to display the new form. So I am changing the
default cursor to wait cursor at that time.

So when I click the button, the TitleBar of the Current form is Flickering
2-3 times .
Simultaneously, the Title changes to "Start" and after a fraction of a
second, it again displays my Program Name. This process repeats for 2-3
times in a second. And finally displays the new form.

What should I do to avoid the flickering in the Title Bar of the current form?

Regards,
Hari
 
Back
Top