Skip to content

Use case: Get errors

christiandelbianco edited this page Jun 18, 2017 · 1 revision

In order to receive errors, add an handler for the OnError event:

var tableDependency = new SqlTableDependency<Product>(connectionString);
tableDependency.OnChanged += this.TableDependency_Changed;
tableDependency.OnError += this.TableDependency_OnError;
tableDependency.Start();
...
private void TableDependency_OnError(object sender, ErrorEventArgs e)
{
    throw e.Error;
}

The Error property in ErrorEventArgs contains the exception coming from TableDependency.