本文介绍了请与线程相关的设计建议的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我有一个表单应用程序,需要在设定的时间间隔查询数据库 ,然后使用从DB。很简单。 我的设计相关问题是.... 我应该创建一个封装计时器的工作线程,(我是相信 也会在计时器触发时创建一个单独的线程),或者我应该创建一个在触发时创建新线程的?或两者都没有? 我应该使用哪种计时器。 " System.Timers.Timer"或者 System.Windows.Forms.Timer 我打算将数据库查询的结果放置到队列中某种类型 然后可以按设定的间隔检索(另一个计时器?)并在表格上显示 。如何使这个队列线程安全? 一些一般的设计指针将不胜感激。 谢谢。 Jon。Hi,I have a form application that needs to query a DB at a set timed intervaland then refresh the form with values received from the DB. Simple enough.My design releated questions are ....Should I create a worker thread that encapsulates a timer, (which I believewill also create a seperate thread when the timer fires) , or should Icreate a timer that creates a new thread when it fires ? Or neither ?Which sort of timer should I use. "System.Timers.Timer" or"System.Windows.Forms.Timer"I was going to ''place'' the results of the DB query into a queue of some sortthat can then be retrieved at a set interval ( another timer ? ) and displaythem on the form. How do I make this queue threadsafe ?Some general design pointers would be appreciated.Thanks.Jon.推荐答案 这篇关于请与线程相关的设计建议的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!