Tap registered on form even after Application.MainPage changed

0
0

I have a menu item to log out and transfer the page. Sometimes when tapping that, the user accidentally taps the GoogleMap behind it, and its mapclick event fires (and crashes because curUser = Nothing)

While I added a check in the Mapclick event to make sure the MainPage was the current form, I feel like after setting a MainPage, other event handlers on the form should stop firing, because we are leaving. Is this intended behavior? thanks

Andrew

 

Private Sub btnLogOut_Click(sender As Object, e As EventArgs) Handles mnuLogOut.Click
CookieHelper.DeleteCredentialCookies() ‘Clear login credentials from cookie.
Application.Session(“user”) = Nothing ‘Clear user variable (in Session)
Me.curUser = Nothing ‘Clear user variable (on form)
Application.Session.IsLoggedOn = False ‘Change Logged on to false
Application.MainPage = New frmLogin ‘Navigate to frmLogin
End Sub

 

 

 

  • You must to post comments
0
0

That’s the correct behavior since the object is valid, leaving or not leaving is an application concept. When you change the MainForm it’s up to your code to dispose the previous one. Otherwise the pages are reusable.

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.