0
我有一個Windows窗體應用程序,它使用通告程序捕獲實體框架中的SQLDependency更改事件,並且所有工作都正常。 EntityChangeNotifier是一個詳細說明SQLDependency的項目。繼續監聽SQLDependency
白衣呼叫while (true)
我可以有一個繼續聽,當我有一個變化的代碼notifer.Changed += (sender, e)
private StartNotifier()
{
var info = new SABIntegrationEntities();
// Notifier
using (var notifer = new EntityChangeNotifier<SpRicezioneSpedizioniLightNotifier, GemapDbContext>(p => p.SPEDIZIONE_STATO_GENERAZIONE == "I" || p.SPEDIZIONE_STATO_GENERAZIONE == "U"))
{
notifer.Error += (sender, e) =>
{
Log.Error(String.Format("[{0}, {1}, {2}]:\n{3}", e.Reason.Info, e.Reason.Source, e.Reason.Type, e.Sql));
};
notifer.Changed += (sender, e) =>
{
e.ContinueListening = false;
bool result = true;
var spedizioniI = info.SpRicezioneSpedizioniLights.Where(x => x.SPEDIZIONE_STATO_GENERAZIONE == "I" || x.SPEDIZIONE_STATO_GENERAZIONE == "U");
foreach (var p in spedizioniI)
{
p.SPEDIZIONE_STATO_GENERAZIONE = "G";
}
}
e.ContinueListening = true;
};
while (true)
{
}
}
}
進入我希望有一個繼續聽這段代碼比雖然(真)好。我該怎麼做?
如果你想你可以找到完整的項目結構在這裏:enter link description here
感謝所有
你能幫助我的代碼嗎? – Ale
@Ale:請參閱我的編輯。 –
感謝您的回覆。如果我有錯誤,我該如何處理唯一的通知程序並重新激活新的通知程序?如果我在聽程序中有相同的錯誤,我想自動重新啓動通知程序。 – Ale