<Rule Id="CA1823" Action="None" /> <!-- Avoid unused private fields -->
<Rule Id="CA1825" Action="None" /> <!-- Avoid zero-length array allocations. -->
<Rule Id="CA2000" Action="None" /> <!-- Dispose objects before losing scope -->
- <Rule Id="CA2008" Action="None" /> <!-- Do not create tasks without passing a TaskScheduler -->
<Rule Id="CA2010" Action="None" /> <!-- Always consume the value returned by methods marked with PreserveSigAttribute -->
<Rule Id="CA2100" Action="None" /> <!-- Review SQL queries for security vulnerabilities -->
<Rule Id="CA2101" Action="None" /> <!-- Specify marshaling for P/Invoke string arguments -->
onSuccess: state => ((TaskCompletionSource<object>)state).SetResult(null)
);
}
- }, ctoken); // We do not need to propagate exception, etc, from reconnect task, we just need to wait for it to finish.
+ }, ctoken, TaskContinuationOptions.DenyChildAttach, TaskScheduler.Default); // We do not need to propagate exception, etc, from reconnect task, we just need to wait for it to finish.
return tcs.Task;
}
else
if (callback != null)
{
completion.Task.ContinueWith(
- (task,state) => ((AsyncCallback)state)(task),
- state: callback
- );
+ (task, state) => ((AsyncCallback)state)(task),
+ state: callback,
+ CancellationToken.None,
+ TaskContinuationOptions.DenyChildAttach,
+ TaskScheduler.Default);
}
return completion.Task;
if (callback != null)
{
completion.Task.ContinueWith(
- (task,state) => ((AsyncCallback)state)(task),
- state: callback
- );
+ (task, state) => ((AsyncCallback)state)(task),
+ state: callback,
+ CancellationToken.None,
+ TaskContinuationOptions.DenyChildAttach,
+ TaskScheduler.Default);
}
return completion.Task;
}
if (callback != null)
{
completion.Task.ContinueWith(
- (task,state) => ((AsyncCallback)state)(task),
- state: callback
- );
+ (task, state) => ((AsyncCallback)state)(task),
+ state: callback,
+ CancellationToken.None,
+ TaskContinuationOptions.DenyChildAttach,
+ TaskScheduler.Default);
}
return completion.Task;
}
{
completion.TrySetException(exc());
}
- });
+ }, CancellationToken.None, TaskContinuationOptions.DenyChildAttach, TaskScheduler.Default);
}
}
}
var connHandler = _connHandler;
Action<Action> wrapCloseAction = closeAction =>
{
- Task.Factory.StartNew(() =>
+ Task.Run(() =>
{
connHandler._parserLock.Wait(canReleaseFromAnyThread: false);
connHandler.ThreadHasParserLockForClose = true;
DecrementPendingCallbacks(release: false);
}
}
- });
+ }, CancellationToken.None, TaskContinuationOptions.DenyChildAttach, TaskScheduler.Default);
}
}
}
// The safest thing to do is to ensure that the connection is broken and attempt to cancel the task
// This must be done from another thread to not block the callback thread
- Task.Factory.StartNew(() =>
+ Task.Run(() =>
{
_parser.State = TdsParserState.Broken;
_parser.Connection.BreakConnection();