0

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

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
CHash11
  • 746
  • 4
  • 14
  • 31

1 Answers1

0

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.

TGH
  • 38,769
  • 12
  • 102
  • 135
  • No I dont have control of the process chnging the DB, however the real issue occurs when I have multiple forms displayed at a same time e.g. consider my application as Visual studio IDE where in we open multiple files as a tabs... the same way I am displaying multiple win forms tabbed next to each other. Here I have a timer in one form which keeps updating data in GrdView and when the control moves to another form that time the timer from the first form does not elapse.. – CHash11 Oct 28 '13 at 05:12
  • I cracked it.. Let me know if any one needs it. Thanks Vikram for your valuable input – CHash11 Nov 22 '13 at 18:15