UI Updating

  • Thread starter Thread starter steve.a.bennett
  • Start date Start date
S

steve.a.bennett

Hi

My Windows Forms applications consists of a listview control
containing of approximately 1000 items, and a worker thread that
performs a lot of execution. After performing some portion of
execution I update the main UI by using a delegate on the main form to
call an update function on the GUI thread.

However, under times of high load my GUI seems to struggle to apply
the updates requested, and portions of the screen (other buttons etc)
are not repainted when I resize the window.

Does anyone have any ideas how I can improve the responsiveness of the
main window. It is important the list view is updated as execution in
the worker thread requires, whilst at the same time the remainder of
the window needs to stay responsive.

Thanks in advance.
 
My Windows Forms applications consists of a listview control
containing of approximately 1000 items, and a worker thread that
performs a lot of execution.

For 1000 items you should definitely use a virtualized list view,
otherwise the updating can take a very long time. See property
ListView.VirtualMode and friends in the MSDN Library.
 
For 1000 items you should definitely use a virtualized list view,
otherwise the updating can take a very long time. See property
ListView.VirtualMode and friends in the MSDN Library.
--http://www.kynosarges.de

Thanks for the information. I will look into the virtual mode and see
whether it helps. One thing I forgot to mention was the fact that each
time the background process updates one of the items, its position can
move in the list. Currently I do this by sorting the list each time I
update the display, however I know that this is a very expensive way
of doing things. Any ideas how I can overcome this problem?

I've only been working with C# for a short amount of time now, so
forgive me if I am asking simple questions.
 
Thanks for the information. I will look into the virtual mode and see
whether it helps. One thing I forgot to mention was the fact that each
time the background process updates one of the items, its position can
move in the list. Currently I do this by sorting the list each time I
update the display, however I know that this is a very expensive way
of doing things. Any ideas how I can overcome this problem?

If the list is already sorted you don't need to re-sort it whenever a
single item changes -- just remove the old item and use binary search
to find the correct spot for the new item. When using a virtualized
list view you don't do this directly on the list view but on a
separate backing collection that holds all the list view items.
 
Come to think of it, you might want to use a backing collection that's
more suitable for frequent updating, such as a binary tree. I think
the SortedDictionary class would be the best choice here.
 
Come to think of it, you might want to use a backing collection that's
more suitable for frequent updating, such as a binary tree. I think
the SortedDictionary class would be the best choice here.
--http://www.kynosarges.de

Thanks. When I update the backing collection will this automatically
update the position of the item in the collection. For instance, I
have objects with a 'status' field, which if errored should move to
the top of the list. In my program I have a thread that checks the
physical devices that the object represents and updates the object
status accordingly. Will i need to remove the object from the
SortedDictionary and re-enter it in order to keep the dictionary
sorted? Or can it be updated on the fly?

Also, with a virtual ListView, how do I make the update to the
display, do I need to invalidate the control?

Thanks
 
Thanks. When I update the backing collection will this automatically
update the position of the item in the collection. For instance, I
have objects with a 'status' field, which if errored should move to
the top of the list. In my program I have a thread that checks the
physical devices that the object represents and updates the object
status accordingly. Will i need to remove the object from the
SortedDictionary and re-enter it in order to keep the dictionary
sorted? Or can it be updated on the fly?

Also, with a virtual ListView, how do I make the update to the
display, do I need to invalidate the control?

Thanks

Cancel that last question, I've found the refresh method!! ;)
 
Back
Top