Form Concepts CodeSample - Detecting Browser close
Categories: Forms, Browser Refresh & Suspend
|
Tags: Developers, Events, Windows & Dialogs, 1. Beginner, 2. Intermediate, Pre v6.3, v6.3, v6.4 and Later, 3. Advanced
Revision:
1
Posted:
04/Oct/2009
Updated:
23/July/2010
Status:
Publish
Types: Code
|
This article will have a few sections added to it soon, based on the following article type skeleton: CodeSample Overview
As all application that run over the Visual WebGui framework are basically web-applications and there is no browser standard for notifying the server that the browser:
- has been closed
- the user refreshed the page
- that the user moved to a different website
we have no specific way of notifying you which of these three specific events occurred. In version 6.1.1 we have added an event that is fired when any one of the three previously actions has occurred. VB.NET CodeNote that the VB.NET code adds logging of the event firing to a file on the server.
Imports Gizmox.WebGUI.Forms
Imports System.IO
Public Class DetectBrowserClose
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
AddHandler Application.ThreadSuspend, AddressOf Application_ThreadSuspend
End Sub
Private Sub Application_ThreadSuspend(ByVal sender As Object, ByVal e As EventArgs)
Dim f As StreamWriter = New StreamWriter("c:\temp\ts.txt")
f.WriteLine("Thread suspended " + DateTime.Now.ToString())
f.Close()
VWGContext.Current.Terminate(True)
End Sub
End Class
C# Code
public void RegisterThreadSuspendHandler()
{
Application.ThreadSuspend += new EventHandler(Application_ThreadSuspend);
}
void Application_ThreadSuspend(object sender, EventArgs e)
{
using (StreamWriter sw = new StreamWriter(@"c:\temp\ts.txt"))
{
sw.WriteLine("Thread suspended " + DateTime.Now.ToString());
}
((IContextTerminate)VWGContext.Current).Terminate(true);
}
About the author
Related Articles
|
Forms
|
|
|
Tags:
Developers, Windows & Dialogs, C#, XML, 1. Beginner, 2. Intermediate, 3. Advanced, Pre v6.3, v6.3, v6.4 and Later
|
|
|
Tags:
Architects, Developers, Windows & Dialogs, 1. Beginner, 2. Intermediate, 3. Advanced, Pre v6.3, v6.3, v6.4 and Later
|
|
|
Tags:
Developers, Theme, 2. Intermediate, 3. Advanced, Pre v6.3, v6.3, v6.4 and Later
|
|
|
Tags:
Developers, Events, Navigation, 1. Beginner, 2. Intermediate, Pre v6.3, v6.3, v6.4 and Later, 3. Advanced
|
|
|
Tags:
Architects, Developers, Windows & Dialogs, 1. Beginner, 2. Intermediate, 3. Advanced, Pre v6.3, v6.3, v6.4 and Later
|
|
|
Tags:
Architects, Developers, Navigation, Windows & Dialogs, 1. Beginner, 2. Intermediate, 3. Advanced, Pre v6.3, v6.3, v6.4 and Later
|
|
|
|