简体   繁体   English

实时更新.NET桌面应用程序

[英]Update .NET desktop application in real-time

I have no experience building a .NET desktop application, all my experience is with the web. 我没有构建.NET桌面应用程序的经验,我的所有经验都在于Web。 A friend of mine has asked me to do a quick estimate for a small desktop application. 我的一个朋友让我快速估算一个小型桌面应用程序。

The application just displays a list of items from the database. 应用程序只显示数据库中的项目列表。 When rows are deleted/added from the database, they need to be deleted/added from the list on the user's desktop. 从数据库中删除/添加行时,需要从用户桌面上的列表中删除/添加行。

Is this done pretty easily in a desktop application, or do I need to do any sort of "reload" every X seconds? 这是在桌面应用程序中轻松完成的,还是我需要每隔X秒进行一次“重新加载”?

The simplest design would involve polling the database every so often to look for new records. 最简单的设计将涉及每隔一段时间轮询数据库以查找新记录。 Adjust the number of seconds between polling to best reflect the appearance of real time and also for performance. 调整轮询之间的秒数,以最好地反映实时外观和性能。

Any design that would allow the database management system to broadcast updates to a desktop application would be quite complicated and (depending on your needs) would most likely be overkill. 任何允许数据库管理系统向桌面应用程序广播更新的设计都会非常复杂,并且(根据您的需要)很可能是过度的。

Elaborating on Andrew Hare's design slightly, I'd suggest that you include some sort of mechanism to 'short-circuit' the refresh cycle when user interaction occurs, ie 稍微阐述了Andrew Hare的设计,我建议你在用户交互发生时包含一些“短路”刷新周期的机制,即

Refresh every x seconds AND Immediatey if the user clicks a control that is deemed to be a critical one AND the required update is less than x records EXCEPT where this would increase the refresh rate beyond a certain throttle value 如果用户单击一个被认为是关键控件并且所需更新小于x个记录的控件,则每隔x秒刷新一次立即执行。除非这会使刷新率超过某个节流值

Basically, you want to give the impression of high performance. 基本上,您希望给人以高性能的印象。 Perceived performance doesn't mean accomplishing tasks quickly, it's more like doing the slow work during periods that you expect the user to be thinking, faffing around or typing something, rather than when they're waiting for a response. 感知性能并不意味着快速完成任务,更像是在您希望用户思考,笨拙或打字的时候做慢工作,而不是等待他们等待响应。 Very few applications are busy even a small fraction of the time they are running - any perceived slow performance is derived from a poor design where the program does too much work at once at the point the user asks for it, requiring them to wait. 很少有应用程序在运行时只占用一小部分时间 - 任何感知到的慢性能都源于一个糟糕的设计,其中程序在用户要求时立即执行太多工作,需要他们等待。 Caching in the background allows you to only assign the bare minimum amount of work to directly respond to user input, improving the user's perception of performance. 在后台缓存允许您仅分配最少量的工作以直接响应用户输入,从而提高用户对性能的感知。

Trying to be directly helpful: 试图直接帮助:

You state you're using .Net - which is handy. 你说你正在使用.Net - 这很方便。 .Net databinding is very rich and powerful, and is quite likely to make this job a breeze. .Net数据绑定非常丰富和强大,很可能使这项工作变得轻而易举。

However - read on... 但是 - 请继续阅读......

There is a chance that it won't do exactly what you want. 有可能它不会完全符合您的要求。 This is where databinding becomes a massive pain. 这就是数据绑定成为巨大痛苦的地方。 Databinding requires certain things to be set up the way .Net wants it, and if they aren't, it's quite a lot of work reimplementing the basic functionality in the way you require. 数据绑定需要以某种方式设置.Net需要它,如果它们不需要,那么以你需要的方式重新实现基本功能是相当多的工作。 In this case, don't hesitate to reach for the MSDN documentation, and StackOverflow. 在这种情况下,请不要犹豫,以获得MSDN文档和StackOverflow。 Ask Early, Ask Often. 早点问,经常问。

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

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