Is your feature request related to a problem? Please describe.
SqlDependency was designed before async was a thing, and it therefore quite hard to work with in a loop.
Describe the solution you'd like
while(!stoppingToken.IsCancellationRequested) {
var command = ...;
var dependency = new AsyncSqlDependency(command, ...);
var whatever = await ProcessResult(command, stoppingToken);
bool falseIfTimeout = await dependency.AwaitDependencyChange(TimeSpan.FromMinutes(1), stoppingToken);
}
Describe alternatives you've considered
It is possible to make an implementation with TaskCompletionSource, but would be so much nicer if it was part of the API.
Additional context
One of the hard things to understand when working with SqlDependency is WHEN the dependency is calculated from. The existing implementation is able to call the callback before the ProcessResult finished, so in worst case you can have an unlimited of queries ongoing, while it keeps giving you notifications about changes. This is especially a problem, if the ProcessResult update the underlying data, and thus triggers it over and over.
Is your feature request related to a problem? Please describe.
SqlDependency
was designed before async was a thing, and it therefore quite hard to work with in a loop.Describe the solution you'd like
Describe alternatives you've considered
It is possible to make an implementation with
TaskCompletionSource
, but would be so much nicer if it was part of the API.Additional context
One of the hard things to understand when working with
SqlDependency
is WHEN the dependency is calculated from. The existing implementation is able to call the callback before theProcessResult
finished, so in worst case you can have an unlimited of queries ongoing, while it keeps giving you notifications about changes. This is especially a problem, if theProcessResult
update the underlying data, and thus triggers it over and over.