Note that there are some explanatory texts on larger screens.

plurals
  1. POForce closing an oracle connection in C#
    primarykey
    data
    text
    <p>I have a report window which shows the results returned from a potentially long running oracle stored procedure. My problem is when the user closes the window the connection to oracle remains open and the potentially long running report doesn't get cancelled.</p> <p>The only way to close the open connection is for either the DBAs to kill them manually or for the user to exit the entire application.</p> <p>I've tried calling <code>Close</code> on the connection from a different thread, but this seems to continuously block. I also tried rolling back a transaction, but this exhibits the same problem.</p> <p>I'm worried that the only solution will be to run the query in a different process (or maybe app domain?).</p> <p>It's likely that I'm missing something obvious, any help would be greatly appreciated.</p> <p><strong>PLEASE READ</strong></p> <p>This question is not about wrapping my connection in a <code>using</code> statement. It is about how to <em>force an oracle connection that is executing a query to close</em>.</p> <p>Example:</p> <ul> <li>Start a thread running a query</li> <li>Stash the connection object somewhere</li> <li><p>Call close on the connection object</p> <pre><code>public void Go() { OracleConnection connection; var queryThread = new Thread( () =&gt; { 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( () =&gt; { connection.Close(); }); closeThread.Start(); } </code></pre></li> </ul> <p>The problem is that this doesn't close the connection, instead the call to connection.Close() blocks waiting for the procedure to execute.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload