更新运行相同数据源的2个应用的UI [英] Update UI of 2 apps running off same data source

查看:59
本文介绍了更新运行相同数据源的2个应用的UI的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个我在WPF vb.net 4.0中创建的应用程序。此应用程序发布并安装在同一本地网络上的多台计算机上,它们都来自中央PC上的相同XML数据文件。



假设只有2个用户(A和B)。



场景:用户'A'更改数据并在UI中触发save命令。



问题:如何自动更新用户'B'的UI以反映保存时的更改,确保所有连接的UI始终显示相同的数据?

I have an application that I created in WPF vb.net 4.0. This application is published and installed on several computers on the same local network and they all pull from the same XML data file on a central pc.

Let's say there are only 2 users (A and B).

Scenario: User 'A' changes the data and fires the save command in the UI.

Question: How do I automatically update the UI for User 'B' to reflect the changes as they are saved, ensuring that all connected UI's are showing the same data at all times?

推荐答案

由于你使用XML文件作为数据库(XML不是数据库!),文件可以改变它想要的一切,代码也不会知道任何关于它的信息。 。对文件的更改永远不会自动通知代码。



您的代码必须使用FileSystemWatcher [ ^ ]实例,用于监视文件的更改。请注意,这可能不是即时通知!



当您收到Changed事件时,您的事件处理程序代码必须启动从加载数据的代码XML文件并将其绑定到您正在使用的网格。
Since you're using an XML file as a "database" (XML is NOT a database!) the file can change all it wants and the code won't know anything about it. Changes to the file are never automatically notifying the code of anything.

Your code would have to use a FileSystemWatcher[^] instance to watch the file for changes. Note, this may NOT be an instantaneous notification!

When you get a Changed event, your event handler code would have to kick off the code that loads the data from the XML file and binds it to the grid you're using.


这篇关于更新运行相同数据源的2个应用的UI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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