// This method is called by the ProcessDispatcher upon a notification for this AppDomain. internal void InvalidateCommandID(SqlNotification sqlNotification) { IntPtr hscp; Bid.NotificationsScopeEnter(out hscp, "<sc.SqlDependencyPerAppDomainDispatcher.InvalidateCommandID|DEP> %d#, commandHash: '%ls'", ObjectID, sqlNotification.Key); try { List <SqlDependency> dependencyList = null; lock (this) { dependencyList = LookupCommandEntryWithRemove(sqlNotification.Key); if (null != dependencyList) { Bid.NotificationsTrace("<sc.SqlDependencyPerAppDomainDispatcher.InvalidateCommandID|DEP> commandHash found in hashtable.\n"); foreach (SqlDependency dependency in dependencyList) { // Ensure we remove from process static app domain hash for dependency initiated invalidates. LookupDependencyEntryWithRemove(dependency.Id); // Completely remove Dependency from commandToDependenciesHash. RemoveDependencyFromCommandToDependenciesHash(dependency); } } else { Bid.NotificationsTrace("<sc.SqlDependencyPerAppDomainDispatcher.InvalidateCommandID|DEP> commandHash NOT found in hashtable.\n"); } } if (null != dependencyList) { // After removal from hashtables, invalidate. foreach (SqlDependency dependency in dependencyList) { Bid.NotificationsTrace("<sc.SqlDependencyPerAppDomainDispatcher.InvalidateCommandID|DEP> Dependency found in commandHash dependency ArrayList - calling invalidate.\n"); try { dependency.Invalidate(sqlNotification.Type, sqlNotification.Info, sqlNotification.Source); } catch (Exception e) { // Since we are looping over dependencies, do not allow one Invalidate // that results in a throw prevent us from invalidating all dependencies // related to this server. if (!ADP.IsCatchableExceptionType(e)) { throw; } ADP.TraceExceptionWithoutRethrow(e); } } } } finally { Bid.ScopeLeave(ref hscp); } }
internal void InvalidateCommandID(SqlNotification sqlNotification) { IntPtr ptr; Bid.NotificationsScopeEnter(out ptr, "<sc.SqlDependencyPerAppDomainDispatcher.InvalidateCommandID|DEP> %d#, commandHash: '%ls'", this.ObjectID, sqlNotification.Key); try { List <SqlDependency> commandEntryWithRemove = null; lock (this) { commandEntryWithRemove = this.LookupCommandEntryWithRemove(sqlNotification.Key); if (commandEntryWithRemove != null) { Bid.NotificationsTrace("<sc.SqlDependencyPerAppDomainDispatcher.InvalidateCommandID|DEP> commandHash found in hashtable.\n"); foreach (SqlDependency dependency in commandEntryWithRemove) { this.LookupDependencyEntryWithRemove(dependency.Id); this.RemoveDependencyFromCommandToDependenciesHash(dependency); } } else { Bid.NotificationsTrace("<sc.SqlDependencyPerAppDomainDispatcher.InvalidateCommandID|DEP> commandHash NOT found in hashtable.\n"); } } if (commandEntryWithRemove != null) { foreach (SqlDependency dependency2 in commandEntryWithRemove) { Bid.NotificationsTrace("<sc.SqlDependencyPerAppDomainDispatcher.InvalidateCommandID|DEP> Dependency found in commandHash dependency ArrayList - calling invalidate.\n"); try { dependency2.Invalidate(sqlNotification.Type, sqlNotification.Info, sqlNotification.Source); } catch (Exception exception) { if (!ADP.IsCatchableExceptionType(exception)) { throw; } ADP.TraceExceptionWithoutRethrow(exception); } } } } finally { Bid.ScopeLeave(ref ptr); } }
// This method is called when a connection goes down or other unknown error occurs in the ProcessDispatcher. internal void InvalidateServer(string server, SqlNotification sqlNotification) { IntPtr hscp; Bid.NotificationsScopeEnter(out hscp, "<sc.SqlDependencyPerAppDomainDispatcher.Invalidate|DEP> %d#, server: '%ls'", ObjectID, server); try { List <SqlDependency> dependencies = new List <SqlDependency>(); lock (this) { // Copy inside of lock, but invalidate outside of lock. foreach (KeyValuePair <string, SqlDependency> entry in _dependencyIdToDependencyHash) { SqlDependency dependency = entry.Value; if (dependency.ContainsServer(server)) { dependencies.Add(dependency); } } foreach (SqlDependency dependency in dependencies) // Iterate over resulting list removing from our hashes. // Ensure we remove from process static app domain hash for dependency initiated invalidates. { LookupDependencyEntryWithRemove(dependency.Id); // Completely remove Dependency from commandToDependenciesHash. RemoveDependencyFromCommandToDependenciesHash(dependency); } } foreach (SqlDependency dependency in dependencies) // Iterate and invalidate. { try { dependency.Invalidate(sqlNotification.Type, sqlNotification.Info, sqlNotification.Source); } catch (Exception e) { // Since we are looping over dependencies, do not allow one Invalidate // that results in a throw prevent us from invalidating all dependencies // related to this server. if (!ADP.IsCatchableExceptionType(e)) { throw; } ADP.TraceExceptionWithoutRethrow(e); } } } finally { Bid.ScopeLeave(ref hscp); } }
internal void InvalidateServer(string server, SqlNotification sqlNotification) { IntPtr ptr; Bid.NotificationsScopeEnter(out ptr, "<sc.SqlDependencyPerAppDomainDispatcher.Invalidate|DEP> %d#, server: '%ls'", this.ObjectID, server); try { List <SqlDependency> list = new List <SqlDependency>(); lock (this) { foreach (KeyValuePair <string, SqlDependency> pair in this._dependencyIdToDependencyHash) { SqlDependency item = pair.Value; if (item.ContainsServer(server)) { list.Add(item); } } foreach (SqlDependency dependency in list) { this.LookupDependencyEntryWithRemove(dependency.Id); this.RemoveDependencyFromCommandToDependenciesHash(dependency); } } foreach (SqlDependency dependency3 in list) { try { dependency3.Invalidate(sqlNotification.Type, sqlNotification.Info, sqlNotification.Source); } catch (Exception exception) { if (!ADP.IsCatchableExceptionType(exception)) { throw; } ADP.TraceExceptionWithoutRethrow(exception); } } } finally { Bid.ScopeLeave(ref ptr); } }
// This method is called when a connection goes down or other unknown error occurs in the ProcessDispatcher. internal void InvalidateServer(string server, SqlNotification sqlNotification) { List <SqlDependency> dependencies = new List <SqlDependency>(); lock (_instanceLock) { // Copy inside of lock, but invalidate outside of lock. foreach (KeyValuePair <string, SqlDependency> entry in _dependencyIdToDependencyHash) { SqlDependency dependency = entry.Value; if (dependency.ContainsServer(server)) { dependencies.Add(dependency); } } foreach (SqlDependency dependency in dependencies) { // Iterate over resulting list removing from our hashes. // Ensure we remove from process static app domain hash for dependency initiated invalidates. LookupDependencyEntryWithRemove(dependency.Id); // Completely remove Dependency from commandToDependenciesHash. RemoveDependencyFromCommandToDependenciesHash(dependency); } } foreach (SqlDependency dependency in dependencies) { // Iterate and invalidate. try { dependency.Invalidate(sqlNotification.Type, sqlNotification.Info, sqlNotification.Source); } catch (Exception e) { // Since we are looping over dependencies, do not allow one Invalidate // that results in a throw prevent us from invalidating all dependencies // related to this server. if (!ADP.IsCatchableExceptionType(e)) { throw; } ADP.TraceExceptionWithoutRethrow(e); } } }
// This method is called by the ProcessDispatcher upon a notification for this AppDomain. internal void InvalidateCommandID(SqlNotification sqlNotification) { List <SqlDependency> dependencyList = null; lock (_instanceLock) { dependencyList = LookupCommandEntryWithRemove(sqlNotification.Key); if (null != dependencyList) { foreach (SqlDependency dependency in dependencyList) { // Ensure we remove from process static app domain hash for dependency initiated invalidates. LookupDependencyEntryWithRemove(dependency.Id); // Completely remove Dependency from commandToDependenciesHash. RemoveDependencyFromCommandToDependenciesHash(dependency); } } } if (null != dependencyList) { // After removal from hashtables, invalidate. foreach (SqlDependency dependency in dependencyList) { try { dependency.Invalidate(sqlNotification.Type, sqlNotification.Info, sqlNotification.Source); } catch (Exception e) { // Since we are looping over dependencies, do not allow one Invalidate // that results in a throw prevent us from invalidating all dependencies // related to this server. if (!ADP.IsCatchableExceptionType(e)) { throw; } ADP.TraceExceptionWithoutRethrow(e); } } } }
private void Invalidate(string server, SqlNotification sqlNotification) { IntPtr hscp; Bid.NotificationsScopeEnter(out hscp, "<sc.SqlDependencyProcessDispatcher.Invalidate|DEP> %d#, server: %ls", ObjectID, server); try { Debug.Assert(this == _staticInstance, "Instance method called on non _staticInstance instance!"); lock (_sqlDependencyPerAppDomainDispatchers) { foreach (KeyValuePair<string, SqlDependencyPerAppDomainDispatcher> entry in _sqlDependencyPerAppDomainDispatchers) { SqlDependencyPerAppDomainDispatcher perAppDomainDispatcher = entry.Value; try { perAppDomainDispatcher.InvalidateServer(server, sqlNotification); } catch (Exception f) { // Since we are looping over dependency dispatchers, do not allow one Invalidate // that results in a throw prevent us from invalidating all dependencies // related to this server. // NOTE - SqlDependencyPerAppDomainDispatcher already wraps individual dependency invalidates // with try/catch, but we should be careful and do the same here. if (!ADP.IsCatchableExceptionType(f)) { throw; } ADP.TraceExceptionWithoutRethrow(f); // Discard failure, but trace. } } } } finally { Bid.ScopeLeave(ref hscp); } }
private void Invalidate(string server, SqlNotification sqlNotification) { IntPtr ptr; Bid.NotificationsScopeEnter(out ptr, "<sc.SqlDependencyProcessDispatcher.Invalidate|DEP> %d#, server: %ls", this.ObjectID, server); try { lock (this._sqlDependencyPerAppDomainDispatchers) { foreach (KeyValuePair<string, SqlDependencyPerAppDomainDispatcher> pair in this._sqlDependencyPerAppDomainDispatchers) { SqlDependencyPerAppDomainDispatcher dispatcher = pair.Value; try { dispatcher.InvalidateServer(server, sqlNotification); } catch (Exception exception) { if (!ADP.IsCatchableExceptionType(exception)) { throw; } ADP.TraceExceptionWithoutRethrow(exception); } } } } finally { Bid.ScopeLeave(ref ptr); } }