简体   繁体   English

一台服务器上的多个客户端

[英]Multiple Clients on 1 server

I am new to GUIs, and i have encountered a problem in my client-server program. 我是GUI的新手,并且我的客户端服务器程序遇到了问题。

My program is like a "customer-support", where multiple clients can use it from different computers simultaneously.My problem is that when one client changes some info, its inserted into the db but the other client will not see it unless I add a "Refresh" button to my gui. 我的程序就像一个“客户支持”,其中多个客户端可以同时从不同的计算机上使用它。我的问题是,当一个客户端更改某些信息时,它将插入数据库中,而另一个客户端则看不到它,除非我添加了“刷新”按钮到我的GUI。

I want the gui to be dynamic and react to different clients actions. 我希望GUI是动态的,并对不同的客户端操作做出反应。 How can you come over this issue? 您怎么能解决这个问题?

EDIT: 1. .net4, 2. sql-server, 3. The actions happends after a button click 编辑:1. .net4,2. sql-server,3.单击按钮后发生的动作

Basically, you have two options: push or poll. 基本上,您有两个选择:推送或轮询。 Push (some central server announcing the change to all the listeners) is more immediate, but demands suitable infrastructure. 推送(某些中央服务器向所有侦听器宣布更改)更加快捷,但需要合适的基础架构。 It also depends on the number of clients you need to support, and how many events are passing through the system. 它还取决于您需要支持的客户端数量,以及通过系统传递的事件数量。 Personally, I'm a big fan of redis pub/sub for this (it is actually what we use for the live updates here on stackexchange, coupled with web-sockets). 就我个人而言,我是redis pub / sub的忠实拥护者 (实际上,这是我们在此处用于stackexchange上的实时更新以及Web套接字的功能)。 But in some cases you can get the database to provide change notifications directly (personally I prefer not to use this). 但是在某些情况下,您可以使数据库直接提供更改通知(我个人不希望使用此功能)。 You may also be able to use events over something like WCF from a central app-server, but that depends on there only being one app-server, which doesn't sound like a good idea to me. 您也许还可以通过中央应用程序服务器通过WCF之类的事件使用事件,但这取决于仅存在一个应用程序服务器,这对我来说听起来不是一个好主意。

The other option is polling - ie have the application automatically query the system periodically (every minute perhaps) to see if the data being displayed has changed. 另一个选择是轮询-即让应用程序定期(可能每分钟)自动查询系统,以查看显示的数据是否已更改。 If you can, using the timestamp/rowversion is a cheap way of doing this. 如果可以的话,使用时间戳/行版本转换是一种便宜的方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM