I am developing an windows forms application in c# .net 4.0.
I want to capture windows logoff event.

Here is the code:

```
    public Form1()
    {
        InitializeComponent();

        SystemEvents.SessionEnding += (s, e) =>
        {
            if (e.Reason == SessionEndReasons.Logoff)
            {
                MessageBox.Show("LogOff");
            }
            else if (e.Reason == SessionEndReasons.SystemShutdown)
            {
                MessageBox.Show("ShutDown");
            }
        };
    }

```

Why isnt my sessionEnding firing?