SqlRequestNotification followed by SqlCacheDependency – strange problem

In my Sql Query Notification session, I had an odd problem. My SqlCacheDependency demo did not receive it’s invalidation. This happened when I set it up in code and also when I set it up in <%Cache> directive on the page. This is a demo that I have done many times in the past year so I was not only mystified, but a little heartbroken.

The only thing that was different was that I had run a SqlRequestNotification demo right before it. This demo listens for the notification on a separate thread.

Now playing with it some more, I see that after I end the first demo (SqlRequestNotification) and start up the SqlCacheDependency… when I change the data, I hit the event handler in the first demo. So that was still hanging around.

What I think is happening is that even when I end the demo and close the page, the file based web server is still there (I can even see it in my system tray right now). The app was still alive and the listener was still listening. So now I am going to have to dig further into SqlRequestNotification in a real scenario even though it is not something I think I will not use frequently. If it wasn’t the web app, it is likely that in this non-best practices demo code, I am not disposing enough things (though the listener’s main task is within a using statement) or something along those lines. Most importantly, it is not a likely scenario to run these two things back to back and therefore this is an unusual problem that I encountered.

I couldn’t really take the time to think this through in the session and probably wouldn’t have come to this conclusion under the small pressure of the clock ticking and those expectant faces in the audience. So I just had to go with “I promise you this works! This is the right code for you to use…” and move on to wrap up the session.

Posted from BLInk!

  Sign up for my newsletter so you don't miss my conference & Pluralsight course announcements!  

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.