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