Skip to content
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
Cannot retrieve contributors at this time
// <copyright file="SqlChangeMonitor.cs" company="Microsoft">
// Copyright (c) 2009 Microsoft Corporation. All rights reserved.
// </copyright>
using System;
using System.Data.SqlClient;
using System.Globalization;
namespace System.Runtime.Caching {
public sealed class SqlChangeMonitor : ChangeMonitor {
private String _uniqueId;
private SqlDependency _sqlDependency;
public override String UniqueId { get { return _uniqueId; } }
private SqlChangeMonitor() {} // hide default .ctor
public SqlChangeMonitor(SqlDependency dependency) {
if (dependency == null) {
throw new ArgumentNullException("dependency");
bool dispose = true;
try {
_sqlDependency = dependency;
_sqlDependency.OnChange += new OnChangeEventHandler(OnDependencyChanged);
_uniqueId = Guid.NewGuid().ToString("N", CultureInfo.InvariantCulture);
dispose = false;
finally {
if (dispose) {
protected override void Dispose(bool disposing) {}
private void OnDependencyChanged(Object sender, SqlNotificationEventArgs e) {