I ran into the same problem. I am creating a data access component that caches some queries from a SQL Server 2005 database. The cache is not valid using this new brilliant, but not new, but not new, SqlDependency approach.
Since this component will be used in ASP.NET, as well as in Forms and Windows Service applications, I am looking for a general way (internally) to call SqlDependency.Stop ().
Using a finalizer was my first idea, and it didn't work. My second attempt was to use an event handler for AppDomain.DomainUnload.
In the end, this seems to work ... But the built-in web server in VS 2005 will hang for 4-5 minutes with a 100% processor by executing SqlDependy.Stop (). In fact, I canβt remember any other process blocking my machine (Pentium M laptop), so reproducible that I could hardly call the task manager ... I did not expect that this is possible from user space and even managed code (SQL Server runs in a different window.) During this time, even Performance Monitor refuses to write anything, so I canβt say if there are many Windows handles or .NET exceptions, or something else ...
Calling from the Application_End event works fine (and only takes a few milliseconds), however it is ASP.NET specific.
Any ideas
Ramprasad Dec 20 2018-11-11T00: 00Z
source share