【问题标题】:Cross client GUI update跨客户端 GUI 更新
【发布时间】:2014-04-23 22:22:20
【问题描述】:

这是我的简化方案,每个客户端都是 LAN 上的 PC:


Client 1:

Add the maximum number: _
Maximum number: 0

Client 2:

Add the maximum number:
Maximum number: 0

所以客户端 1 将“1”保存为最大数量,客户端 2 应自动接收更新并更改为:


Client 2:

Add the maximum number: _
Maximum number: 1 (last updated by Client 1 on 23/04/2014 at 19:16) 

使用 c# winforms 和 sql sever 2012(用于保存数字)实现此目的的最佳方法是什么。

【问题讨论】:

    标签: c# sql-server multithreading user-interface client


    【解决方案1】:

    方法有很多:

    1-轮询:每个用户定期向数据库服务器请求更新

        Pros: very easy to implement, secure
        Cons: consumes too much bandwith and db server process
    

    2-集中式TCP服务器:一台专用机器监听连接,每个客户端连接到它并通知事件,服务器将这些事件重定向到相应的客户端。

        Pros: minimum bandwith, not much process required
        Cons: more complex to program, need a machine to act as server
    

    3-分散的UDP通知:如果客户端在同一个局域网中,那么您可以在该网络中广播UDP数据包,这样每个客户端都会收到任何客户端发送的每个通知。

        Pros: minimum bandwith, 0 process required, no need for central server
        Cons: it's not guaranteed a packet arrives it's destination (but in a close LAN usually they do).
    

    所以,这些是最常见的方法,现在您必须平衡您的要求并选择一种。

    在您的情况下,我会尝试 UDP 方式,如果您需要确保接收数据包,那么您的客户端可以等待来自事件目标的响应,如果在 X 时间内他们没有收到响应然后再次广播数据包,这样就可以保证接收到了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-06-27
      • 2011-08-15
      • 1970-01-01
      • 1970-01-01
      • 2017-12-04
      • 1970-01-01
      • 1970-01-01
      • 2011-03-20
      相关资源
      最近更新 更多