2017-03-31 15 views

回答

1

您可以在設置SqlCacheDependency的地方啓用通知和EnableTableForNotifications。

不要忘記,如果你想禁用它,你將不得不調用DisableNotifications和/或DisableTableForNotifications。

也就是說,您應該在Application_Start和Application_End方法中啓動和停止偵聽器。

protected void Application_Start(object sender, EventArgs e) 
{ 
    SqlDependency.Start("YOUR CONNECTION STRING"); 
} 

protected void Application_End(object sender, EventArgs e) 
{ 
    SqlDependency.Stop("YOUR CONNECTION STRING"); 
} 

More info here

相關問題