문제

I have a DataGridView on my windows forms and I want to display real time data from a SQL Server database on it. I am using Windows.forms.Timer to fetch data from DB every 1 sec and binding it to DataGrid but some times on doing some other UI operations the Timer.Elapsed is not fired exactly at interval of 1 sec but is queued and 2-3 events fires at a time. Pleas let me know the best way to implement such a scenario

Regards, Harshal

도움이 되었습니까?

해결책

If you're in control of the process that changes the data in the DB I would consider an event driven model instead where you issue an event that the UI can subscribe to when the data changes. That way you can avoid unnecessary polling.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top