Open Zqasim132 opened 2 years ago
Tagging subscribers to this area: @roji, @ajcvickers See info in area-owners.md if you want to be subscribed.
Author: | Zqasim132 |
---|---|
Assignees: | - |
Labels: | `area-System.Data`, `untriaged` |
Milestone: | - |
cc @ajcvickers
Any ADO.NET that uses DbCommand as the base class will have the StateChange event and should (but not must) fire that event when the state changes.
However it should be noted that the only real way to know if a connection is broken is to try to use it and see if fails, whether you do that or the system does that doesn't really matter but be aware that the state change event may be out of date if no-one has tried to use the connection and may then flip when you do try to use it.
I want to get a SQL Server disconnection event notification in my Database Service which is built in .NET 6 with ADO.net. Actually for now we are detecting the connections health or state by continuously executing a select query in a separate Thread after a specific time intervals. I want a behaviour like SignalR when server is shut down or if any network error occurs it gives an event notification on which we can perform some relevant actions. Is there any way to achieve this. Thanks!