How to speed up .NET winforms rendering

前端 未结 5 1830
慢半拍i
慢半拍i 2021-01-12 01:28

I have a series of forms and navigate between them.

Each form has a set of controls for which I load properties from SQLite database and this is the long (about 1s)

相关标签:
5条回答
  • 2021-01-12 01:52

    this link has some nice solution, as far as i think BackgroundWorker process should help. http://devcomponents.com/blog/?p=361

    0 讨论(0)
  • 2021-01-12 02:07

    Sorry. This is what threading is for. "Cross-thread operation issues" are well defined and there are common patterns for dealing with them. Just reduce the places where threads interact to a minimum (in this case, it would be a single place--after data is loaded) and it becomes trivial.

    There are also some classes which make multithreading in a winforms app much easier, as they abstract away the interaction between threads. The BackgroundWorker (link to blog post about it) will perform work on another thread for you, and notifies you when its done by firing an event on the UI thread. You get the benefits of multithreading without any of the pitfalls.

    0 讨论(0)
  • 2021-01-12 02:07

    I've found that loading Winform controls, like combo boxes and listboxes, load a lot faster when they are pointing to Views instead of a table itself, especially if you can limit the view to be leaner compared to the control having to look through an entire table.

    0 讨论(0)
  • 2021-01-12 02:18

    There is a simple way to speed up perceived performance of many controls, especially data intensive ones like listviews, listboxes, combo boxes etc.

    Before you populate them call the BeginUpdate() method and when done call the EndUpdate(). This disables the redrawing of the control until you're done populating it with data.

    0 讨论(0)
  • 2021-01-12 02:18

    Back in VB days I used LockWindowUpdate API. Since this takes a window handle, it should be usable also with WinForms. Though, never tried.

    0 讨论(0)
提交回复
热议问题