1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
   |  
public partial class timeControlSF2 : ServiceBase
    {
        private static bool sessionOpen = false;
        ...
 
        public timeControlSF2()
        {
            InitializeComponent();
 
            ...
 
            SystemEvents.SessionSwitch += new SessionSwitchEventHandler(SystemEvents_SessionSwitch);
 
        }
        ...
 
void SystemEvents_SessionSwitch(object sender, SessionSwitchEventArgs e)
        {
            System.Windows.MessageBox.Show("raison: "+e.Reason.ToString(), "tests",
                   System.Windows.MessageBoxButton.OK,
                   System.Windows.MessageBoxImage.None,
                   System.Windows.MessageBoxResult.OK,
                   System.Windows.MessageBoxOptions.ServiceNotification);
            switch (e.Reason)
            {
                case SessionSwitchReason.SessionLock: sessionOpen = false; break;
                case SessionSwitchReason.SessionLogoff: sessionOpen = false;
                    this.mess.Visible = false; this.mess.mess.check = true; break;
                case SessionSwitchReason.SessionLogon: sessionOpen = true; break;
                case SessionSwitchReason.SessionUnlock: sessionOpen = true; break;
            }
        } | 
Partager