Imports System.Web Imports System.Reflection Public Class GlobalBase Inherits System.Web.HttpApplication Private oApp As Framework.App = Nothing Sub Application_End() Dim lcShutDownMessage As String = "" Dim lcShutDownStack As String = "" Dim lnDateNow As Double = Date.Now.Ticks Dim lnDuration As Double = 0 Dim loHttpRuntime As HttpRuntime = Nothing Dim loUpdate As Framework.Update = Nothing oApp = App.oApp loUpdate = New Framework.Update(oApp) ' If we have an IISApplicationCycle table If Not oApp.Tables("IISApplicationCycle") Is Nothing Then lnDuration = ((lnDateNow - oApp.nDateNow) / 10000000) loHttpRuntime = DirectCast(GetType(System.Web.HttpRuntime).InvokeMember("_theRuntime", _ BindingFlags.NonPublic Or BindingFlags.Static Or BindingFlags.GetField, Nothing, Nothing, Nothing), HttpRuntime) ' If it is running If Not loHttpRuntime Is Nothing Then lcShutDownMessage = DirectCast(loHttpRuntime.[GetType]().InvokeMember("_shutDownMessage", _ BindingFlags.NonPublic Or BindingFlags.Instance Or BindingFlags.GetField, Nothing, loHttpRuntime, Nothing), String) lcShutDownStack = DirectCast(loHttpRuntime.[GetType]().InvokeMember("_shutDownStack", _ BindingFlags.NonPublic Or BindingFlags.Instance Or BindingFlags.GetField, Nothing, loHttpRuntime, Nothing), String) End If ' Update the record loUpdate.cAlias = "IISApplicationCycle" loUpdate.nPrimaryKey = oApp.nID loUpdate.ParameterAdd("Duration", lnDuration) loUpdate.ParameterAdd("ShutDownMessage", lcShutDownMessage) loUpdate.ParameterAdd("ShutDownStack", lcShutDownStack) If Not loUpdate.Update() Then Exit Sub End If End If End Sub End ClassThe application pool are set to recycle at 06h00.
' Get the process ID oApp.nProcessID = Process.GetCurrentProcess().Id