Application.ApplicationExit - when is it fired?

0
0

Hi,

I have some database connection at session level. I detect some Pooled connection request timed out errors when connecting to database (Oracle, if that matters).

I close/dispose connection on ApplicationExit event, but in logs (my logs) there are no entries proving that this event is fired.

Please tell me where is the best moment/place to dispose my database connection?

  • You must to post comments
0
0

Hi Adrian,

this was logged as #2443 and is fixed in our latest development build (2.1.16).

Best regards
Frank

  • You must to post comments
0
0

Tried this as a temp workaround:

 Application.Session.DetectSessionDisposed = new DetectSessionDisposed(Application.Session);


 internal class DetectSessionDisposed
 {
 dynamic session;

 public DetectSessionDisposed(dynamic session)
 {
   // just in case you need to access objects in the session
   this.session = session;
 }

  ~DetectSessionDisposed()
  {
    // this code is executed when the session is expired and the GC collects the objects.
  }
 }
  • Adrian Zagar
    Stupid question…but where should I put that code? I put it in Main() but it’s never called. (tried just to close the browser).
  • Luca (ITG)
    The class in a class file. The creation and assignment to the session in Program.Main().
  • Adrian Zagar
    When I said “it’s never called” I was just not patient enough. ~DetectSessionDisposed was called 27 minutes after I closed the browser. And at that moment, Application.Session.oracleConnection was null so I couldn’t close the connection (stored in Application.Session). It was already closed (that’s good) but keeping it for 27 minutes can reach the maximum number for database server.
  • You must to post comments
0
0

The ApplicationExit event is (should be) fired when the session is disposed. The session is disposed approximately after sessionTimeout * 2 seconds of “inactivity” or if you call Application.Exit(). Inactivity usually means that the client has lost connection (which could mean it was turned off) or the browser or tab are closed. If the app is loaded on a tab it may never expire because there is a keepalive heartbeat – it will show the built-in session-expiring form unless you handle the SessionExpired event.

But… there appears to be a regression causing it to be fired only if you call Application.Exit(). I’m not sure when it was introduced. Will log the bug, should be in the next build.

The session is disposed correctly though allowing the GC to dispose any related object so the connections should still be disposed by the GC.

 

  • You must to post comments
Showing 3 results
Your Answer

Please first to submit.