You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using the following code to react to the NotificationProcessStopped event:
// Listener contains the SqlDependencyEx instanceListener.NotificationProcessStopped+=(sender,args)=>{Task.Run(async()=>{awaitTask.Delay(5000);AttemptReconnect();});};privatevoidAttemptReconnect(){try{Listener.Stop();Listener.Start();}catch{Task.Run(async()=>{awaitTask.Delay(5000);AttemptReconnect();});}}
If I run this code and stop the SQL Server to simulate a disconnect, I am receiving an ObjectDisposedException: The CancellationTokenSource has been disposed in the Stop() method when the _threadSource.Token.IsCancellationRequested property is read in line 567 on the second reconnect attempt (and every reconnect attempt thereafter).
When I change this to _threadSource.IsCancellationRequested everything works fine.
The text was updated successfully, but these errors were encountered:
So first time the token stops, then second time there is no token because it was disposed and now you want to use the token source to check if cancellation is requested?
From this if ((_threadSource == null) || (_threadSource.Token.IsCancellationRequested))
to this if ((_threadSource == null) || (_threadSource.IsCancellationRequested))
Hi,
I'm using the following code to react to the
NotificationProcessStopped
event:If I run this code and stop the SQL Server to simulate a disconnect, I am receiving an
ObjectDisposedException: The CancellationTokenSource has been disposed
in theStop()
method when the_threadSource.Token.IsCancellationRequested
property is read in line 567 on the second reconnect attempt (and every reconnect attempt thereafter).When I change this to
_threadSource.IsCancellationRequested
everything works fine.The text was updated successfully, but these errors were encountered: