Web Application event live cycle
Which events come in which order is really a good question and you should know a few facts here. First the order of events in a very small web application with two pages and one button to switch to second page:
- App.Open
- Session.Constructor
- Session.Open
- WebPage1.Button1.Open
- WebPage1.Open
- WebPage1.Resized
- WebPage1.Shown
- WebPage1.Button1.Shown
- WebPage1.Button1.Action
- WebPage2.Open
- WebPage2.Resized
- WebPage1.Hidden
- WebPage1.Button1.Hidden
- WebPage2.Shown
- WebPage2.Close
- WebPage1.Button1.Close
- WebPage1.Close
- Session.Close
- Session.Destructor
- WebPage2.Destructor
- WebPage1.Destructor
- App.Close
Now the user presses a button with the mouse. The button action fires and we use "webpage2.show" to switch to other page. As you see the second page is created with open event firing and resized. Than first page hides, before second page is shown.
When the user closes the browser window, nothing happens until a timeout after which the session is destroyed. So you see the webpages get their Close events including all the controls on them. The session is also closed and destructor fires. Finally also the destructors of the webpages fire. And on the end, when the web app quits, the app.close event is called.
Important note: Webpages are not released from memory before the session closes.
Sample project: livecycle.rbp.zip