开发者

c# refresh large data after each second

i am facing a problem.

i have a list view which is in detail form..

it has large quantity of data to displ开发者_如何学编程ay. and the data is continuously updating after each second.

in current situation list view is flickering. how can i solve this issue


Instead of just refreshing the page to pull in the new content maybe you could use jquery and JSON?

So use jquery to send the request for more information every X seconds that calls an ashx page. The ashx page grabs the data from your database and then return you should return the result values as json so jquery can easily parse result and display onto the screen.

Great tutorial of doing this type of thing using jquery, c# and web services below:

Encosia - using jquery to consume aspnet

jquery json documentation

Hope that's some help to you.

EDIT: My answer assumed you were using asp.net web forms. I've never used win forms (apart from my old vb 6 days) so not sure if you can work with jquery or not there.


In WinForms to prevent this flicker effect, you need to user a BackgroundWorker object to run your process in a separate thread. Then, after an acceptable interval, use the BackgroundWorker's ReportProgress to update the list appropriately.

http://msdn.microsoft.com/en-us/library/system.componentmodel.backgroundworker.aspx http://www.dotneat.net/2009/02/10/BackgroundworkerExample.aspx http://dotnetperls.com/backgroundworker

This will allow you to call the list's Refresh() method regularly without forcing the flicker since the processes will be in different threads.


Use a FastObjectListView from the ObjectListView project -- a wrapper around the .NET WinForms ListView control. The fast version is a virtual list that uses double buffering to give flicker free updates.

I've used it for listviews with more than 50,000 objects and the update time is less than 0.5 seconds (on a mid-range laptop).

BUT even with almost instant updates, your users are going to have a hard time using a control that changes its contents every seconds.


A part of the flickering in WinForms application can be solved by doublebuffering the form and / or controls within it. See also: Anti Flicker Graphics using Double Buffering

SetStyle(ControlStyles.UserPaint, true);
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
SetStyle(ControlStyles.DoubleBuffer, true);

Alternatively, look into the Control.DoubleBuffered property:

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜