Use of SqlDependency blocks executing method

大憨熊 提交于 2019-12-25 02:53:07

问题


I am experimenting with SqlDependency at the moment. I have a watching console application that really does not do anything than creating the SqlDependency object on a defined SqlCommand and then call dependency.Start(); The statement to be watched contains 2 inner joins.

To test this now, I wrote another console app that updates a record that should change the result of the defined query. The data in these tables is about 1 million rows / table. Now when calling the method that executes the update statement, the background checking process of SQL Server takes really long (5secs) which blocks the calling method. update without watching is about 20ms.

is there maybe an async approach that does not block my calling method? or what do you suggest to do? i also thought about setting the notification object on my SqlCommand. This creates an entry in sys.dm_qn_subscriptions. But what is the best way to react on entries in this view? use a seperate service that uses polling to this table? i really liked the concept of hanging onto an event when something changes.

来源:https://stackoverflow.com/questions/22932734/use-of-sqldependency-blocks-executing-method

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!