title: How do I check there is no OnChangeEventHandler before adding a new one in Sql Server
body: <p>I understand that I need to constantly renew the OnChangeEventHandler every time a callback is received.</p>
  
  <p>I would like to ensure that there is no existing handler before adding a new one.</p>
  
  <p>How do I do this? Is there a count? (see HERE comment)?</p>
  
  <pre><code>   public void InitialiseDependency(Action onDependencyMethod)
      {
          this.onDependencyMethod = onDependencyMethod;
          SqlDependency.Start(connectionString, null);
  
          using (SqlCommand command = new SqlCommand(
                  "SELECT [Symbol] FROM [dbo].[tblOrders] WHERE [Status] = 'NEW'",
                  conn))
          {
  
              SqlDependency dependency = new SqlDependency(command);
  
              //HERE if (dependency.OnChangeEventHandlers.count()) &gt; 0 { return; }
  
              dependency.OnChange += new OnChangeEventHandler(OnDependencyChange);
  
              using (SqlDataReader reader = command.ExecuteReader())
              {
                  // Process the DataReader.
              }
          }
      }
  </code></pre>