WinForms Tips & Tricks - Boosting Application Performance

WinForms Team Blog
12 July 2018

This second Tips&Tricks post is all about application performance. We have some recommendations to share - hopefully they will help you increase performance of your own applications! The list starts with items that are generally applicable and should be considered for most, if not all, applications. Further down you find a few approaches that apply to specific use cases.

Upgrade to the latest DevExpress installation

It may seem cheeky to list this as the first item, but it is meant quite seriously: among the most effective things you can do to optimize performance for your application is to use our latest release. We constantly allocate significant developer time to an ongoing process of performance analysis and improvement. We often blog about specific performance achievements, but many individual points go unannounced!

As an example, we recently optimized our skinning mechanism to fill areas with solid colors when possible and avoid more expensive image drawing. For modern “flat” skins without gradients, this improvement is quite significant.

Skin painting optimizations

And now on to other suggestions!

Pre-compile your apps using NGen

This first tip applies to any Windows Forms application, whether you are a DevExpress customer or not.

When you build a .NET application in Visual Studio, it is compiled into Microsoft Intermediate Language (MSIL, sometimes IL for short). When a user launches the application, its MSIL code is compiled into machine code by the “just in time” (JIT) compiler. An important advantage of this approach is that the JIT compiler can employ optimizations depending on the user’s target platform, but the process can cause noticeable delays. External DLLs may be loaded in addition to your own application, which means that any delay doesn’t depend on the size of your code alone.

If you struggle with start-up delays in your application due to JIT compilation, you should utilize the Native Image Generator (Ngen.exe) tool in the .NET Framework SDK. This tool compiles the MSIL code in an assembly into native code just like the JIT compiler does, but you can control when this happens - for instance, you can run it as part of the installation process. When the end-user eventually runs your application, the CLR loads the precompiled code and no additional compilation is required.

Refer to this MSDN blog post for detailed information, or check out our Support Center ticket dedicated to NGen.

Try DirectX rendering

You can enable DirectX hardware acceleration to accelerate all painting operations and to benefit from high power graphics cards in end-user PCs. The benefits are greater when High DPI screens are being used, but even at standard DPI resolutions, output performance is improved. For instance, check out these GIF animations in our documentation to compare PictureEdit performance with and without DirectX when the editor shows large images. More details about DirectX support in our WinForms products, and a list of controls that benefit from it, are available at this documentation URL.

Use deferred loading

Deferred loading is a general-purpose technique that suggests to “load” (i.e. to create, instantiate or retrieve) information as well as costly UI elements only when it becomes clear that they are definitely needed. In other words, what an end user can’t see doesn’t need to exist (yet). This mindset is a good basic recommendation because an application that employs deferred loading tends to feel faster and snappier to the end user.

Some DevExpress controls have built-in support for deferred loading. For instance, the Document Manager component supports it based on the QueryControl event, loading only those documents that are visible at a certain point in time. Here is the documentation for the Document Manager feature. A very similar approach is also implemented in the Navigation Frame.

Deferred Document Manager Loading

Load Data Grid images asynchronously

Another more specialized deferred loading mechanism is implemented in the Data Grid. If your grid is populated with records that include large (or several) images, you should definitely try the Asynchronous Image Load feature. With this feature enabled, the grid displays its UI - and supports user interaction! - without waiting for images to load. Images are loaded asynchronously and displayed with an optional animation effect when they become available.

Data Grid Asynchronous Image Loading

The feature is highly customizable: you can cache images after the first load so they don’t need to be reloaded when the user scrolls the grid. The image loading order can be randomized, the loading indicator customized, or image loading overridden entirely for specific records.

Disable skins and visual effects

This last item is not a general recommendation, but it might be useful in specific scenarios. One example of such a situation is a Remote Desktop Services environment. In this setup, remote users constantly receive snapshots of an application’s visual appearance. The more visual effects the application has, the more updates are required. If the connection is poor and the refresh rate low, the application may seem unresponsive. In some low-performance environments you may run into similar issues, for example when you target embedded systems with WinForms applications.

To run DevExpress WinForms applications without optional visual effects, you can selectively take several steps on application start-up. As an example, this code snippet shows detection of a Windows Terminal Server session.


if (System.Windows.Forms.SystemInformation.TerminalServerSession) {
  Application.VisualStyleState = VisualStyleState.NoneEnabled;

  UserLookAndFeel.Default.UseWindowsXPTheme = false;
  UserLookAndFeel.Default.Style = LookAndFeelStyle.Flat;

  WindowsFormsSettings.AnimationMode = AnimationMode.DisableAll;
  WindowsFormsSettings.AllowHoverAnimation = DevExpress.Utils.DefaultBoolean.False;

  BarAndDockingController.Default.PropertiesBar.MenuAnimationType = AnimationType.None;
  BarAndDockingController.Default.PropertiesBar.SubmenuHasShadow = false;
  BarAndDockingController.Default.PropertiesBar.AllowLinkLighting = false;

Here are some details about aspects of this code sample:

LoadApplicationSettings - by default, options applied on the DevExpress Project Settings page are loaded from App.config during form initialization. This process would override options applied from code during application startup. An explicit call to LoadApplicationSettings applies the settings right away so that changes made in code after this call can take precedence.

WindowsFormsSettings.AnimationMode - this setting affects those control animation properties that have the default value DefaultBoolean.Default. If you manually enable specific animation effects (e.g. AllowSortAnimation in a Data Grid), the control-specific settings have priority over the global flags in WindowsFormsSettings.

Finally, note that if you use the Ribbon Control, it cannot be shown without a theme and it will always have at least the default DevExpress Style skin applied. It might be better to use the Bar Manager instead if you disable skins. This will result in a consistent UI and save significant resources, since the Ribbon consumes about twice as much memory as the Bar Manager.

Any thoughts?

Please let us know your own experiences with performance optimizations, or any thoughts you have about our suggestions! The more input we have from our customers, the more effective we can be with optimization work and future plans for performance specific features!

11 comment(s)
Christopher Todd
Christopher Todd

Since you mentioned DirectX rendering and Terminal Server Session in the same blog, I've always been curious if DirectX would still provided any benefit in a Citrix environment. Thanks for the Tips!

12 July, 2018
Viatcheslav Vassiliev
Viatcheslav Vassiliev

I would also add ProfileOptimization - .

12 July, 2018

Is there going to be a Tips & Tricks for WPF?

12 July, 2018
frank vdb
frank vdb

Pete was just ahead of me. I'm also interested in the recommended visual effects settings for remote sessions.

12 July, 2018
Dmitry (DevExpress)
Dmitry (DevExpress)

Viatcheslav Vassiliev

great tip indeed, thanks!

PETE N, frank van den bergh

Thanks for asking, I'll pass your requests to the WPF team!

13 July, 2018
Steve Sharkey
Steve Sharkey

Nothing wrong with your first suggestion, when asked to investigate performance queries with a system some years ago I go a demo version of Redgates' ANTS Performance Profiler. I loved the tool but it would have been an utterly pointless expenditure since the vast majority of time taken in the app was within DevExpress components. Hence upgrading to the latest version of the components gives you an instant performance boost.

13 July, 2018
Bitahwa Bindu
Bitahwa Bindu

Great tips. Is there a recommended tips for loading mailmerge document template (snap or docx) when the form load, it slows down the form loading.

Thanks for the tips

13 July, 2018
Uwe Keim
Uwe Keim

I've tried that "Pre-compile your apps using NGen" trick several times before, and never ever saw any significant improvements.

Actually, I saw no improvements at all.

15 July, 2018
Yulia (DevExpress Support)
Yulia (DevExpress Support)

@Bitahwa Bindu

In our RichEditControl/Snap, document formatting is performed in a background thread. Thus, loading a large document into our controls should not freeze UI. If you notice different behavior, please contact us in our Support Center  ( and attach a sample project/document that shows the problem. We will research it locally.

16 July, 2018
Baldur Fürchau
Baldur Fürchau

Disable Skin in a TerminalSession is not an option, because the Skin is the look and feel of my application and not microsoftsstyle.

Also DirectX on TerminalSession works only, if you have a virtual graphiccard and also RemoteFX installed. If not, DirectX will be emulated and dramatically slows down the performance.

Disable Animanition makes also only sence if DirectX is not usable.

17 July, 2018
Ngen made my application very fast!!
30 July, 2019

Please login or register to post comments.