当其他用户进行更改时刷新Windows程序吗? [英] Refreshing Windows program when other users make changes?

查看:84
本文介绍了当其他用户进行更改时刷新Windows程序吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

场景:


  • 4个用户启动连接到基于数据库的To-Do的同​​一客户端程序(Winforms)的单独实例

  • 第一个用户选择第三个待办事项列表项。

如何更新/刷新其他3个用户屏幕以反映项目#3不再可用?

How do I update/refresh the other 3 users screens to reflect that item #3 is no longer available?

我以为是一个包含最近更新日期时间戳的表。然后计时器将每隔几秒钟检查一次,看是否有任何更改。

My thought was a table that contains the last update date-time stamp. Then a timer would check every few seconds to see if there have been any changes.

UPDATE1:

感谢所有人-肯定有很多有效答案。

Thanks to all - there are definitely a number of valid answers.

我采用了Icemanind 建议。

推荐答案

是。最好的方法是实现推送类型的系统。这就是它的工作方式。每当有人在客户端上单击某些内容时,客户端就会向服务器发送一条消息。服务器将需要接收该信号,然后服务器将向所有连接到该服务器的客户端发送刷新消息。

Yes. The best way to do this is to implement a "push" type system. Here is how it would work. Whenever someone clicks something on the client end, the client would send a message to the server. The server would need to receive this signal and then the server would send out a refresh message to all clients connected to the server.

我不知道您的客户端或服务器进行了编码,但是您需要在服务器上创建一个线程,以侦听来自客户端的传入消息,并在接收到消息并将其放入队列后返回侦听更多消息。服务器上的第二个线程需要处理队列中的消息。

I don't know your client or server is coded, but you'll want to create a thread on the server that "listens" for incoming messages from clients and once it receives a message, puts it into a queue, the returns to listening for more messages. A second thread on the server needs to process the messages in the queue.

在客户端,您还需要第二个线程来侦听来自服务器的传入消息。收到消息后,便可以处理该消息并采取任何必要的措施。

On the client side, you'll also want a second thread that listens for incoming messages from the server. Once a message is received, it can process the message and take whatever action is necessary.

有关客户端/服务器和套接字编程的相当不错的教程可以在这里找到: http://www.codeproject.com/KB/IP/serversocket.aspx

A pretty decent tutorial on client/server and socket programming can be found here: http://www.codeproject.com/KB/IP/serversocket.aspx

当然,这是一个指南。

Of course, it is a guide. You will need to modify it as you see fit.

希望这很有意义,祝您好运!

Hope this makes sense and good luck!

这篇关于当其他用户进行更改时刷新Windows程序吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆