I want a datagridview to be updated every few seconds, using Timers in C#, I bring the data from sql, what I don't know is if this is going to make the system slower, any recommendation will be of great help, Regards
I want a datagridview to be updated every few seconds, using Timers in C#, I bring the data from sql, what I don't know is if this is going to make the system slower, any recommendation will be of great help, Regards
Here you have several options, (surely there are others so let's wait for comments and other answers to expand). Depending on the criticality of your update requirement, they are more complex to configure, maintain and above all "perform problem/error detection"
OPTION 1: "polling"/Polling: You can do the "polling" mode, that is, with timers (every certain time) with some strategy not to bring data but to detect the change and then update data
OPTION 1.2: Idem to the previous one but here instead of consulting the original query or tables that can be expensive, a secondary table is created (you could help with Tables in Memory of SQL Server) that later an event (AFTER INSERT/DELETE etc) updates this table to detect a change (more performant to query this table than the original query and detect change). This is more manual
OPTION 2: Using SqlDependency . Here the "underlying" configuration and permissions that you need in SQL Server is a bit more complete since it uses SQL Broker
OPTION 3: Using SqlNotificationRequest . I didn't try this but it seems similar to the previous one (it seems that everything behind uses SQL Broker)
Recommendation: If you don't have a team/person who manages SQL Server with these configurations (that is, who knows about the subject), I propose OPTION 1.1, which is in the middle of everything. And the improvement with the new SQL server to use in this type of tables that must "fly" SQL Server In-Memory OLTP (I leave an example of use https://github.com/fernandezja/sqlserver-in-memory-oltp -as-queues )
These links can help you
I hope it helps or guides you.