Forum Discussion
"Thread was interrupted from a waiting state" from DbConnectionPool.CleanupCallback
Thanks for posting your issue here.
Here is the solution of your problems:
https://stackoverflow.com/questions/35979245/vb-net-does-sqlconnection-get-closed-automatically-in-a-try-catch-if-exception-i
let me know if you have any query on this.
Best Regards,
AddWebSolution
Hi AddWebSolution,
Thank you for your reply, but I'm aware of the need to close every DbConnection. The issue was that I just couldn't find in my app where I would be opening a connection without a proper close or dispose of it.
Meanwhile I’ve decompiled the System.Data.dll, to check the code of the CleanupCallback() function, and find out that the code line where it is raising the exception is the one calling WaitOne() function, and that means that in fact it is the thread that is running the function that is interrupted.
So, I conclude from this that must be some other process, clearly outside my application, that is doing that, probably due to external factors or low-level issues in the operating system or .NET Framework itself and hasn’t nothing to do with connections not closed.
In this context, the CleanupCallback() function is a method of the System.Data.ProviderBase.DbConnectionPool class, that it is typically called by the connection pool's internal management mechanism.
Given this context, the "Thread was interrupted from a waiting state" exception that occurs within the CleanupCallback() function is likely associated with the thread that is responsible for managing the connection pool, and not with individual connections that are being opened and closed by the application.
The thread interruption seems to be occurring within the internals of the ADO.NET connection pool management, probably due to factors outside the control of the application, such as system-level issues or low-level thread management by the .NET Framework itself.
So, what can it be? How can I investigate the system environment for potential external factors or specific configurations that could be affecting the behavior of the thread pool and connection pool management?
Regards,
Pedro