Skip to content

Commit 1346d10

Browse files
cheenamalhotraViktorHofer
authored andcommitted
Fix Connection Resiliency in SqlClient (#62)
1 parent f562d52 commit 1346d10

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/libraries/System.Data.SqlClient/src/System/Data/SqlClient/SqlConnection.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -911,7 +911,7 @@ internal Task ValidateAndReconnect(Action beforeDisconnect, int timeout)
911911
{
912912
}
913913
// use Task.Factory.StartNew with state overload instead of Task.Run to avoid anonymous closure context capture in method scope and avoid the unneeded allocation
914-
runningReconnect = Task.Factory.StartNew(state => ReconnectAsync((int)state), timeout, CancellationToken.None, TaskCreationOptions.DenyChildAttach, TaskScheduler.Default);
914+
runningReconnect = Task.Factory.StartNew(state => ReconnectAsync((int)state), timeout, CancellationToken.None, TaskCreationOptions.DenyChildAttach, TaskScheduler.Default).Unwrap();
915915
// if current reconnect is not null, somebody already started reconnection task - some kind of race condition
916916
Debug.Assert(_currentReconnectionTask == null, "Duplicate reconnection tasks detected");
917917
_currentReconnectionTask = runningReconnect;

0 commit comments

Comments
 (0)