The closing force of the oracle compound in C #

I have a report window that displays the results returned from a potentially long oracle stored procedure. My problem is when the user closes the window, the connection to the oracle remains open, and the potentially long running report is not canceled.

The only way to close an open connection is for database administrators to kill them manually, or to exit the entire application.

I tried calling Closeon a connection from another thread, but this seems to be continuously blocked. I also tried to cancel the transaction, but this shows the same problem.

I am worried that the only solution would be to start the request in another process (or perhaps in the application domain?).

It is likely that I am missing something obvious, any help would be greatly appreciated.

READ PLEASE

This question does not concern the transfer of my connection to the operator using. It is about how to force an oracle connection that executes a request to close.

Example:

  • Run the thread executing the request
  • Copy the connection object somewhere
  • Click on the connection object

    public void Go()
    {
        OracleConnection connection;
        var queryThread = new Thread(
            () =>
                {
                    using (connection = OpenOracleConnection())
                    {
                        // execute stored proc that takes 45 mins
                        // raise an event with the data set we load
                    }
                });
    
        Thread.Sleep(3000); // give it time to be useless
    
        var closeThread = new Thread(
            () =>
                {
                    connection.Close();
                });
        closeThread.Start();
    }
    

The problem is that this does not close the connection; instead, calling connection.Close () blocks the execution of the procedure.

+5
source share
3 answers

Hm, API, / . , , , , kill . , - , .

, .

, . , , .

, ;)

+2

, / , :

select s1.username || '@' || s1.machine
   || ' ( SID=' || s1.sid || ' )  is blocking '
   || s2.username || '@' || s2.machine || ' ( SID=' || s2.sid || ' ) ' AS status
   from v$lock l1, v$session s1, v$lock l2, v$session s2
   where s1.sid=l1.sid and s2.sid=l2.sid
   and l1.BLOCK=1 and l2.request > 0
   and l1.id1 = l2.id1
   and l2.id2 = l2.id2;
+1

.NET, Dispose

using(var conn = /* your connection */) {
    // do your stuff

    conn.Close();
} // this will automatically call .Dispose()

, , .

0

All Articles