How to speed up .NET winforms rendering

I have a number of forms and navigate between them.

Each form has a set of controls for which I load properties from the SQLite database, and this is a lengthy (about 1 second) operation that does not give users a better feeling, because the form is gradually being drawn.

I am not completely against the delay, but I would like the form to be drawn when all the data is loaded. I would like to avoid new threads, because this will lead to problems with cross-threads.

Is there a good solution besides speeding up the entire application by caching the downloaded data?

+6
performance winforms rendering
source share
5 answers

There is an easy way to speed up the perception of the performance of many controls, especially for data like listviews, listboxes, combo boxes, etc.

Before filling them out, call the BeginUpdate () method and when done call EndUpdate (). This disables the repainting of the control until you fill it with data.

+4
source share

Unfortunately. This requires a thread. "Cross-threading problems" are clearly defined and there are common patterns for working with them. Just reduce the places where the threads interact with a minimum (in this case it will be one place - after loading the data), and it becomes trivial.

There are also some classes that simplify multithreading in a winforms application, as they abstract the interaction between threads. BackgroundWorker (link to a blog post about this) will do the work for another thread for you and let you know when this is done, an event in the user interface thread. You get the benefits of multithreading without any pitfalls.

+2
source share

I found that loading Winform controls, such as combo boxes and lists, loads a lot faster when they point to "Views" instead of the table itself, especially if you can limit the view to be more compact compared to the control, view the entire table.

+1
source share

In the days of VB, I used the LockWindowUpdate API. Since this accepts a window handle, it should also be used with WinForms. Although, I never tried.

0
source share

This link has some nice solution, it seems to me that the BackgroundWorker process should help. http://devcomponents.com/blog/?p=361

0
source share

All Articles