HOW TO CHECK USER DISCONNECTION IN VISUAL WEB GUI


In a Visual Web GUI application sometimes it is required to know, if user connected or not.
Disconnection can be occurred due to several reasons i.e.
1.     Enters another URL and navigates away.
2.     Closes the browser window.
3.     Refreshes the page. ( Sessions reset sometimes)
Following code snippet will show you the event that can be implemented to check such behaviours:
using System;
using Gizmox.WebGUI.Forms;

namespace Test
{
    public partial class Index : Form
    {
        public Index()
        {
            InitializeComponent();

            //This event is used for checking disconnection
Application.ThreadSuspend += new EventHandler(Application_ThreadSuspend);
        }

        void Application_ThreadSuspend(object sender, EventArgs e)
        {
            // TODO: Add Code to do the tasks after disconnection
        }
    }
}

No comments:

Post a Comment