The Database instance is not a problem, we have our own cache below and by specifying the same alias name you will get the same database instance.
the code looks good to me. The only question is: can the same sender make several asynchronous requests in parallel. In this case, because the scope is not thread safe by default, you might get errors. Those error are usually exceptions and not a blocking app.
Do you see the complete app hanging or are there hanging requests?
Our connection handling is as follows:
If the scope has to execute a server request is gets an connection from the pool. If the result of the request is read completely the connection goes back into the pool. There are some cases where the connection is not immediately given back to the pool.
1. If you have a query result with more then 50 rows and you do not read the result completely. The result is a cursor on the server and as long as you do not read the result completely or dispose the result we have to keep the connection at the scope.
2. If you use AUTOINC keys and ask for the key before the new object is inserted. Here we have to flush the object to the server to get the key. This means we have to keep the server transaction open until the scope transaction is committed.
3. If you call transaction.flush
All the best,
the Telerik team