I have a proof of concept app that I am working on. It is set to be cookieless in the json file and that works correctly.
I have setup code in my program.vb so that my app doesn’t timeout on the sessionTime
AddHandler Application.SessionTimeout, AddressOf Application_SessionTimeout
Private Sub Application_SessionTimeout(sender As Object, e As System.ComponentModel.HandledEventArgs)
e.Handled = True
I am loading my for with the standard code in the Sub Main()
Dim window As New Main()
This all works fine, and I can have my app run for hours without anyone touching it. (It is a dashboard app so it doesn’t need any interaction)
form “main”, If I click on a menu option, it launches a new form using the sub
Again, this works fine, no timeout
The problem comes when I try to read what form to open from an xml file. My xml file is this serialized object
Public Class uiSession
Public Property LastAccessed As DateTime = Date.MinValue
Public Property ActiveForm As String = String.Empty
It has 2 methods in it ReadXML and SaveXML
If I use the ReadXML and load the form based off this, my session will time out after about 5 minutes. The code used to launch the page is the same as above, mnuBill_Run()
it looks like this:
Dim xsession As New uiSession
xsession = xsession.ReadXML()
If xsession.ActiveForm <> “” Then
Select Case xsession.ActiveForm
If I delete the XML file, so it passed by the if xsession.activeForm, it doesn’t time out.
So, after all that, why is it timing out if I open the form based off the saved object?
It is the issue I described in my last comment. This is what happens in your code:
Execution Path 1: Program.Main -> window.Show() -> AddHandler SessionTimeout -> Done.
User clicks MenuItem1 -> LoadTest() -> frm.LoadData() -> frmShowDialog() -> Modal Idling (thread is suspended).
Timeout event from client -> Application_SessionTimeout -> Handler = true -> Done.
Execution Path 2: Program.Main -> window.Show() -> LoadTest() -> frm.LoadData() -> frmShowDialog() -> Modal Idling (thread is suspended).
Timeout event from client -> There is no handler attached since Main() is in a modal loop.
Solution: Move AddHandler before window.Show(), or better not use ShowDialog(), use frm.ShowModalMask = true and frm.Show()
Luca, I have written a really tiny app that demonstrates the problem.
If you run this on a server (not inside of VS2015), you will need to click on the menu option “Test”. This will open a form that, using a timer will update the time every 2 seconds.
It will run and run and not have the session timeout.
If you go into Window1.vb and uncomment the LoadTest() in the Main_Load and run it, the frmTest form will load, and the timer will update the time label every 2 seconds. Wait around 6-7 minutes and it will throw up the message that the session will time out in xxx.