SqlDependency async support
- Dominant language
- C#
- Stars
- 989
- Forks
- 340
- Avg merge
- 4d 18h
- Merged PRs (30d)
- 69
Description
### 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
```csharp
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.
Contributor guide
Assessment
This issue has not been assessed yet.