我的当前.net应用程序有一个问题,是后续,当更新数据库行或插入新行时,我的.net服务必须读取这些更改并提交打印命令。线程和数据库读取建议
我想实现的功能如下:
public void OnStart()
{
ThreadMgmt pthread = new ThreadMgmt();
pthread.printNotification += new pthread.DatabaseChanged();
pthread.frequency = 2000;
ThreadStart ts = new ThreadStart(pthread.Wait);
Thread t = new Thread(ts);
t.Start();
}
void ReadDataBase() {...}
void Printing(){...}
public class ThreadMgmt
{
public delegate void UpdateDelegate();
public event UpdateDelegate Notify;
private int frequency {set;get;}
public void Wait()
{
for (int i = 0; i <= Freq; i++)
{
Thread.Sleep(this.frequncy);
Notify();
}
}
}
但我需要约约线程和循环事件概念的一些帮助,我想知道是否有人要面对同样的问题,如何解决它...
谢谢
我没有看到问题?什么不起作用?还是仅仅是一个表现问题? –
我想告诉应用程序,如果满足条件不要停止工作,并继续寻求数据库更改 –