Update C# client whenever database is updated

后端 未结 3 1265
我在风中等你
我在风中等你 2020-12-05 17:04

I am using MySQL with C# / Visual Studio 2008. I need to know any method so that if one user updates the database, all the logged in users over the network, are notified tha

相关标签:
3条回答
  • 2020-12-05 17:37

    Using the SqlDependency Class is a better way to make all your data driven more faster and efficient. It just remove the need of constantly re-query your database checking every time when a changes is made in the data.

    0 讨论(0)
  • 2020-12-05 17:45

    Quite a long answer, but your best bet would be something like SqlCacheDependency.

    Also you could use something called the "Reverse AJAX" technique, which is used by Google Mail notifications, and talked about here: How does incoming mail notification on Gmail works?

    Besides those two, your own other options AFAIK is simple server polling.

    Also, you haven't mentioned what your client is.

    Is it a public web site on the internet? Is it an intranet app, it is a WPF app?

    If it's a web site, you're best best is client-side callbacks using the Reverse AJAX technique i mentioned.

    0 讨论(0)
  • 2020-12-05 17:56

    You probably need to design some kind of poll functionality in your client. For example, you can send a request each minute asking the database "Have you updated anything since [date the client latest got updates]?" If the database answers true, you let the client request the full set of updates. If not, you let it sleep another minute.

    0 讨论(0)
提交回复
热议问题