|
Article relates to
|
RadControls for WinForms, Q2 2009 SP1
|
|
Created by
|
Nikolay Diyanov
|
|
Last modified
|
Sep 23, 2009
|
|
Last modified by
|
Nikolay Diyanov
|
PROBLEM
When you register/load a theme in your project, this registration takes some time when you start your application. If you have a large number of themes, this time may become noticeable. If you application initially starts with only one theme applied to the RadControls on the form (for example ControlDefault theme), this means that you do not need to have the other themes loaded when the application is started. So, in order to descrease application loading time we can load the other themes in a separate thread.
SOLUTION
In this article we will demonstrate what is the benefit of loading themes in a separate thread on form load. Let's make a small application of one RadForm and a RadComboBox. By RadComboBox we will set the ApplicationThemeName property.
Let's first load the predefined theme components in the main thread:
Please note that when we make new instances of the theme components we actually register the themes that are contained in these components.
In order to measute the time of the form load, we set the following code in the Program.cs:
Let's now start the application in Release mode. We get an average timespan of 1422 ms.
Let's create the theme component objects in a separate thread. We will do this with the help of a BackgroundWorker in the Form_Load event handler:
In this case we get an average timespan of 890 ms. This result compared to the 1422 ms means that we decrease the loading time with about 532 ms. The good thing about loading themes in different thread is that they are already loaded when we want to use them, for example after the form is loaded, I select "Office2007Black" from the RadComboBox and I get the Office2007Black style successfully loaded in the application.

Please find attached a sample project below which demonstrates the described approach.
Please
Sign In
to rate this article.