我的當前.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();
}
}
}
但我需要約約線程和循環事件概念的一些幫助,我想知道是否有人要面對同樣的問題,如何解決它...
謝謝
我沒有看到問題?什麼不起作用?還是僅僅是一個表現問題? –
我想告訴應用程序,如果滿足條件不要停止工作,並繼續尋求數據庫更改 –