I want to use RadListControl to display the logs of the ongoing large process in background thread. I will be adding hundred thousands of items into the control in main thread.
But to make everything simple, before adding item to the control, I am checking if the item count is more than 100, if it is more than 100 I am removing the top most Item, then only I am adding the new item. After adding I am scrolling the listbox control down to the last item.
This process may run for more than 10 hrs and my application may not respond as it is dealing with too much of items every seconds.
I am looking for most efficeint way to do this as with listboxcontrol after running for about 1 hr application is not able to handle the number of items and not responding.
I am using following code:
RadListDataItem newItem = new RadListDataItem(message);
if (radListControl1.Items.Count > 100)
But if I am using windows listboxcontrol I am able to do without any problem.
if (listBox1.Items.Count > 100)
listBox1.SelectedIndex = listBox1.Items.Count - 1;
I want to use RadListControl because it can handle html syntax.
Please suggest something on this. I can even switch to another control which supports html code.
4 Answers, 1 is accepted
you could try something like the following, using a background worker and updating the scroll via the progress changed event
Let me know how that goes
Just a small updated Form1.cs to make it safer (so not to perform illegal cross thread operations).
Did this help? If so please remember to mark as answer. If you need further assistance, let me know
Richard`s solution is working without any delay when you are adding up to about 100 items a second. From 100 items upwards there is some delay and when the garbage collector passes the delay in UI response time is increased.
I played with the solution and I was able to make the UI 100% responsive even when adding more than 500 items per second. What I did was to add a Queue<string> where the HTML-like text was stored and a Timer. On every tick of the timer an item is dequeued from the queue and is added to the RadListControl and if there are more than 100 items one is removed. However in this solution there is a potential risk of overflowing the queue, but if the average items add rate is not too high it should cope.
I have attached this modified solution for you to look at.
Another thing is that if you will be displaying that much of items per second they will be unreadable to the user. You might think of some mechanism for reducing the number of displayed items.
I hope we have been of help. If you need further assistance, do not hesitate to ask.
the Telerik team