-
Notifications
You must be signed in to change notification settings - Fork 317
Cleanup | AsyncHelpers Generic State #3705
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
base: main
Are you sure you want to change the base?
Changes from all commits
8383e19
8119c0c
3df7400
6500240
f4eea9f
8450aaa
547af51
847fd25
cb6d1f9
dd48b59
5b29b7f
153b764
3584c99
14fed23
7684fe7
da6ef3c
f8ccc85
45ef372
0e3250f
aabd04f
ba65f50
453197e
db584d7
2340c83
e20f118
76770ef
c7d06b9
2035cf5
bbc9193
3560027
8ae7470
3f5cfa9
10f39c9
e2a1027
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -10,10 +10,10 @@ | |||||
| using System.Threading; | ||||||
| using System.Threading.Tasks; | ||||||
| using Microsoft.Data.Common; | ||||||
| using Microsoft.Data.SqlClient.Utilities; | ||||||
|
|
||||||
| #if NETFRAMEWORK | ||||||
| using System.Security.Permissions; | ||||||
| using Microsoft.Data.SqlClient.Utilities; | ||||||
| #endif | ||||||
|
|
||||||
| namespace Microsoft.Data.SqlClient | ||||||
|
|
@@ -308,14 +308,12 @@ private IAsyncResult BeginExecuteReaderInternal( | |||||
| if (writeTask is not null) | ||||||
| { | ||||||
| AsyncHelper.ContinueTaskWithState( | ||||||
| writeTask, | ||||||
| localCompletion, | ||||||
| state: Tuple.Create(this, localCompletion), | ||||||
| onSuccess: static state => | ||||||
| { | ||||||
| var parameters = (Tuple<SqlCommand, TaskCompletionSource<object>>)state; | ||||||
| parameters.Item1.BeginExecuteReaderInternalReadStage(parameters.Item2); | ||||||
| }); | ||||||
| taskToContinue: writeTask, | ||||||
| taskCompletionSource: localCompletion, | ||||||
| state1: this, | ||||||
| state2: localCompletion, | ||||||
| onSuccess: static (this2, localCompletion2) => | ||||||
| this2.BeginExecuteReaderInternalReadStage(localCompletion2)); | ||||||
| } | ||||||
| else | ||||||
| { | ||||||
|
|
@@ -1605,21 +1603,19 @@ private Task RunExecuteReaderTdsSetupContinuation( | |||||
| string optionSettings, | ||||||
| Task writeTask) | ||||||
| { | ||||||
| // @TODO: Why use the state version if we can't make this a static helper? | ||||||
| return AsyncHelper.CreateContinuationTaskWithState( | ||||||
| task: writeTask, | ||||||
| state: _activeConnection, | ||||||
| onSuccess: state => | ||||||
| taskToContinue: writeTask, | ||||||
| state1: this, | ||||||
| state2: Tuple.Create(ds, runBehavior, optionSettings), | ||||||
| onSuccess: static (this2, parameters) => | ||||||
paulmedynski marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
| { | ||||||
| // This will throw if the connection is closed. | ||||||
| // @TODO: So... can we have something that specifically does that? | ||||||
| ((SqlConnection)state).GetOpenTdsConnection(); | ||||||
| CachedAsyncState.SetAsyncReaderState(ds, runBehavior, optionSettings); | ||||||
| this2._activeConnection.GetOpenTdsConnection(); | ||||||
| this2.CachedAsyncState.SetAsyncReaderState(parameters.Item1, parameters.Item2, parameters.Item3); | ||||||
| }, | ||||||
| onFailure: static (exception, state) => | ||||||
| { | ||||||
| ((SqlConnection)state).GetOpenTdsConnection().DecrementAsyncCount(); | ||||||
| }); | ||||||
| onFailure: static (this2, _, _) => | ||||||
|
||||||
| onFailure: static (this2, _, _) => | |
| onFailure: static (this2, parameters, exception) => |
paulmedynski marked this conversation as resolved.
Show resolved
Hide resolved
Copilot
AI
Nov 14, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The parameter name should be onTimeout to match the method signature of SetTimeoutException. Using onFailure will cause a compilation error.
Copilot
AI
Oct 20, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The TODO comment indicates that throwing the exception in the onFailure handler may not have the intended effect. The exception is rethrown but might not propagate correctly since this is in a continuation callback. This should either be removed if truly ineffective, or the exception handling should be revised.
Uh oh!
There was an error while loading. Please reload this page.