如何将桌面应用程序与网页连接?
我正在使用 VS2010 - C# - WPF 我构建了一个桌面应用程序,该应用程序显示了一些值。 这些值是从我也制作的网页中获取的。
现在,每次我更改网页上的值时,都必须更改应用程序上的值。
但我不希望应用程序一直刷新,因为刷新率很低,所以我希望网页通知所有应用程序。单击网站上的按钮。
这样的事可能吗?知道任何人都可以下载该应用程序,但除了我之外没有人可以访问该网站?
I am using VS2010 - C# - WPF
I have a desktop application that I built, and this application shows some values.
these values are brought from a web page that I made too.
Now everytime I change the values on the webpage the values must be changed on the applications.
But I don't want the applications to keep refreshing because the refresh rate is low, so I want the webpage to notigy all apps. on a button click from the website.
is such thing possible ? knowing that anyone can download the application but no one can access the website but me ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我会将您的问题视为“如何让服务器向客户端推送通知”的学术问题并回答,但我认为更好、更常见的解决方案是客户端应用程序在服务器端点上进行轮询,并且正如 Tejs 所说,自我更新。
至于问题,您必须
您将面临的首要问题是,如果客户端没有响应该怎么办,如何维护列表 - 内存中或数据库中等等。
I will consider your problem as an academical one of "How to get the server to push notification to the client" and answer, but I think the better, and more common solution is for the client application to do polling on a server endpoint, and update itself, as Tejs says.
As for the question, You have to
Top issues you will face are, problems like what to do if client does not respond, how to maintain the list - in-memory or in-DB and so on.
这里不会有任何魔法;这取决于您的更新间隔。如果您希望它们在应用程序首次启动时获得最新值,那么您只需在应用程序加载方法中发出 Web 请求即可。否则,您将需要在应用程序中实施某种轮询以获取更新,只是间隔很长(例如每个请求之间间隔 2 小时等)。
There's not going to be any kind of magic here; it depends on your update interval. If you want them to just get the freshest value on the applications first start, then you can simply make the web request in the application load method. Otherwise, you will need to implement some kind of polling for updates in your application, just on a long interval (say 2 hours between each request, etc).