每当更新数据库时更新 C# 客户端

Update C# client whenever database is updated(每当更新数据库时更新 C# 客户端)
本文介绍了每当更新数据库时更新 C# 客户端的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用带有 C#/Visual Studio 2008 的 MySQL.我需要知道任何方法,以便在一个用户更新数据库时,通知所有通过网络登录的用户,通知发生了更改.如果我通过我的应用程序登录数据库,当时数据库中最新记录的序列号是 10,然后我有权限的人更新了数据库中的记录,同时我被通知数据库已更新为新记录.常见的例子是 MSN Messenger 在朋友上线时提醒他...虽然我真的不想要那个弹出窗口,但警报功能是这样的......

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 that a change has been occurred. If i logged in the database through my application, at that time the serial no of the latest record in the database was 10, and then i someone with the privileges updates the record in the database and at the same time i am being notified that the database has been updated with a new record. Common example can be of MSN messenger's alert for a friend when he gets online... Though i really don't want that popup, but alert functionality is something like that...

还有一件事要问:我想要一个功能,比如如果记录的状态没有更新(比如说超过 3 个小时),那么我希望所有用户也能得到关于这个问题的警报.所有记录都需要此功能,而不是专门针对新记录.

One more thing to ask: I want a functionality like if a record's status is not updated (for say about more than 3 hours), then i want all users to get alert about that issue also. This functionality is needed for all of the records, not specifically for new records.

推荐答案

您可能需要在客户端中设计某种投票功能.例如,您可以每分钟发送一个请求,询问数据库自 [客户端最新更新日期] 以来您是否更新过任何内容?"如果数据库回答 true,您让客户端请求完整的更新集.如果没有,你让它再睡一分钟.

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.

这篇关于每当更新数据库时更新 C# 客户端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

DispatcherQueue null when trying to update Ui property in ViewModel(尝试更新ViewModel中的Ui属性时DispatcherQueue为空)
Drawing over all windows on multiple monitors(在多个监视器上绘制所有窗口)
Programmatically show the desktop(以编程方式显示桌面)
c# Generic Setlt;Tgt; implementation to access objects by type(按类型访问对象的C#泛型集实现)
InvalidOperationException When using Context Injection in ASP.Net Core(在ASP.NET核心中使用上下文注入时发生InvalidOperationException)
LINQ many-to-many relationship, how to write a correct WHERE clause?(LINQ多对多关系,如何写一个正确的WHERE子句?)