2017-03-31 16 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

相关问题