Polling database for updates from C# application

与世无争的帅哥 提交于 2019-12-24 21:14:12

问题


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!


回答1:


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.




回答2:


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




回答3:


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



来源:https://stackoverflow.com/questions/454751/polling-database-for-updates-from-c-sharp-application

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!