Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed CancellationTokenSource Issue #47

Merged
merged 2 commits into from
Mar 5, 2024

Conversation

ghost
Copy link

@ghost ghost commented Feb 27, 2024

Pass cancellation timeout

IDbDataParameter[] parameters,
Func<SqlDataReader, Task<T>> callback)
{
return _dbResources.ChooseDb(database).ExecuteAsync(async (connectionStr, _) =>
{
var stopwatch = Stopwatch.StartNew();
Exception error = null;
var cancellationTokenSource = new CancellationTokenSource();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an IDisposable, can we wrap it in using?

IDbDataParameter[] parameters,
Func<SqlDataReader, Task<T>> callback)
{
return _dbResources.ChooseDb(database).ExecuteAsync(async (connectionStr, _) =>
{
var stopwatch = Stopwatch.StartNew();
Exception error = null;
var cancellationTokenSource = new CancellationTokenSource();
cancellationTokenSource.CancelAfter(taskCancellationTimeOutInMilliSecs);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the operation that you want to include in the timer? Only the query execution, or opening the connection as well? If the first then should we initialize this closer to where it's consumed? Or if you want to timeout even if opening the connection takes a long time, then should we pass the token to connection.OpenAsync() as well?

@szaboopeeter szaboopeeter merged commit d0c6daa into master Mar 5, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants