1

I am using SqlTableDependency https://tabledependency.codeplex.com/ in my .NET 4.5 windows service. The service is monitoring and working correctly but I was trying to find an elegant way of handling a reconnect if for some reason the SQL connection is lost. When I force a disconnect in SQL I notice the service will hit the TableDependency_Error event handler. I suppose I could just put a reconnect in there but was wondering if there was a better way.

briank
  • 83
  • 11
  • I haven't used SqlTableDependency. Is there any reason you need to keep the SQL connection open? In theory you should open late and close early. .NET takes advantage of connection pooling so re-opening a closed connection is lightning fast – Frode Mar 26 '17 at 20:00
  • @Frode The connection has to stay open in order for the service to be notified a change occured in the table being monitored. This gets rid of the annoying timers to ping the database and check for changes. The moment you stop the connection, the moment the monitoring stops. – briank Mar 26 '17 at 20:48

0 Answers0