轮询数据库以获取来自 C# 应用程序的更新

发布于 2024-07-12 22:39:50 字数 542 浏览 8 评论 0原文

我正在尝试创建我的第一个“真正的”C# 应用程序 - 一个小型宠物项目,用于帮助安排工作中的同行评审。

由于实施任何新事物所涉及的流程/官僚主义数量惊人 - 以及我暂时在远离管理层的视线、用自己的时间做这件事的事实 - 我将用MS Access MS Jet Engine 后端(即访问 mdb 文件),因为我向同事部署此应用程序的方式受到限制。

我的问题是:如何间歇性地轮询数据库以从数据库获取更新(新请求的评论、其他开发人员请求信息的消息等)?

我是否应该在每个需要信息的表单上放置一个计时器,并在发生更新时刷新所有内容?

编辑:
我正在专门寻找有关如何实现计时器的建议。 我无法在工作站上安装东西,我无法访问服务器(存储空间之外),而且由于公司的安全要求,我无法自己托管它,因为我们的客户有荒谬的国防部限制。

我想我已经弄清楚了这一点,因为“表单计时器”解决方案工作得很好(当我说我想要 CLI 版本的辅助解决方案时,我不知道我在想什么,因为它显然不需要.. 太晚了)。

谢谢!

I'm attempting to create my first "real" C# application - a small pet project to help schedule peer reviews at work.

Due to the insane amount of process/bureaucracy involved in implementing anything new - as well as the fact that I'm doing this away from managements eyes, on my own time, for the time being - I'm going to be writing this with an MS Access MS Jet Engine backend (i.e. an access mdb file) due to restrictions on how I can deploy this application to my co-workers.

My question is: how do I poll the database intermittently to grab updates (new requested reviews, messages from other developers requesting info, etc.) from the database?

Should I just drop a Timer on each form that needs the info and refresh everything when an update has occurred?

Edit:
I'm looking for advice specifically on how to implement the timer. I can't install things on workstations, I don't have access to servers (outside of storage space), and I can't host this myself due to the company's security requirements since our client has ridiculous DoD restrictions.

I guess I've figured this out anyway, since the "timer on form" solution works just fine (I don't know what I was thinking when I said I wanted a secondary solution for a CLI version as it clearly isn't needed.. it's very late).

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

十雾 2024-07-19 22:39:50

您可以启动后台工作线程以无限循环进行刷新,并在每次循环迭代的结束(或开始)时休眠。

You could start a background worker thread to do the refreshes in an infinite loop, and sleep at the end (or beginning) of each loop iteration.

小姐丶请自重 2024-07-19 22:39:50

将您的应用程序开发为 aspnet MVC 应用程序。 这样它就是一个网站,开发人员只需刷新页面即可获得最新结果。 这将在很多方面帮助您:无轮询、无访问、Web 界面(非常方便)、[太多而无法提及]

从这里开始 - http://www.asp.net/learn/mvc-videos/video-395.aspx

编辑:更多链接:

(这些都是很棒的视频)

* http://www.asp.net/learn/ mvc-videos/video-396.aspx

* http://www.asp.net/learn/ mvc-videos/video-360.aspx

* http://www.asp.net/learn/ mvc-videos/video-361.aspx

develop your application as a aspnet MVC app. this way it's a web site and developers can simply refresh pages to get the latest results. this will help you in many ways: no polling, no access, web interface (very handy), [too many to mention]

start here - http://www.asp.net/learn/mvc-videos/video-395.aspx

EDIT: more links:

(these are great vids)

* http://www.asp.net/learn/mvc-videos/video-396.aspx

* http://www.asp.net/learn/mvc-videos/video-360.aspx

* http://www.asp.net/learn/mvc-videos/video-361.aspx

绝情姑娘 2024-07-19 22:39:50

orrite..我会崩溃的。

我轮询访问数据存储的最佳建议是使用 System.IO.FileSystemWatcher 来监视 mdb 文件所在的文件夹。 通过这种方式,您可以编写代码以一定时间间隔进行轮询,但仅在 Changed 事件触发时进行轮询。 这应该会减少CPU和磁盘访问。

希望这可以帮助。 :D

orrite.. i'll crumble.

my best suggestion to poll the access data store would be to use a System.IO.FileSystemWatcher to monitor the folder where the mdb file lives. this way you can craft your code to poll at an interval but only when the Changed event fires. this should chew less cpu and disk access.

hope this helps. :D

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文