tags:

views:

23

answers:

1

Hi all,

I have made an application which showns a lists of client. You can open a client, and the client's details are shown.

My application takes quite a long time to start, so I want to improve the startup performance.

In pseude-code, my main window looks like this

<Window>
    <c:WelcomeAnimation Visibility="Visible" />
    <c:ClientList Visibility="Collapsed" />
    <c:ClientDetails Visibility="Collapsed" />
</Window>

Now, before the main window is shown, I see that the ClientList and ClientDetails are intialized. This is time consuming, so I want to delay this initialization and do it when the main window is shown and the WelcomeAnimation is running.

This will give at least the perception that the application starts faster.

Question: What are my options in window design. I like to have the above XAML view. I can of course do everything in code-behind, so my main window XAML will be nothing more than

<Window /> 

but maybe there are better options I'm not aware of?

A: 

This depends. When the startup time is because of code you have written yourself (e.g. calling web services or fetching data from the database), don't execute that code on initialize, but fire off a background thread/ThreadPool task and run the code there.

When the startup time is actually just because of the control being loaded (e.g. it is a very complex control with many visuals), you have two options. Either put in a replacement panel instead of the control and fill that once the animation is displayed. The second option is to just bite the bullet.

One more thing to note. If the startup times actually are because of a huge amount of visuals, the initialization will have to be done on the UI thread anyway, so the animation will not be playing while loading the control.

Pieter