Пример #1
0
        /// <summary>
        /// Attach the OnExit event handler, to do some clean up before exiting
        /// </summary>
        public static void AttachOnExitEventHandler(IView view)
        {
            Application.ApplicationExit += (object sender, EventArgs e) =>
            {
                if (Main.Devices == null)
                {
                    return;
                }

                //Turn off the BR
                Blocker_Redirector.BRMainSwitch = false;

                foreach (var device in Main.Devices)
                {
                    device.Value.Redirected = false;
                    device.Value.Blocked    = false;
                    device.Value.Limited    = false;
                }

                if (Blocker_Redirector.BRTask != null && Blocker_Redirector.BRTask.Status == System.Threading.Tasks.TaskStatus.Running)
                {
                    //Wait for the BR task to finish
                    Blocker_Redirector.BRTask.Wait();

                    //Dispose of the BR task
                    Blocker_Redirector.BRTask.Dispose();
                }

                //Terminate the scanner
                Scanner.CloseAllCaptures(view);

                //Clean all notifications
                NotificationAPI.ClearNotifications();
            };
        }
Пример #2
0
        public void AttachOnExitEventHandler()
        {
            Application.ApplicationExit += (object sender, EventArgs e) =>
            {
                try
                {
                    var devices = _view.ListView1.Objects.Cast <Device>().ToList();

                    foreach (var device in devices)
                    {
                        device.Redirected     = false;
                        device.Blocked        = false;
                        device.LimiterStarted = false;
                    }

                    GetClientList.CloseAllCaptures(_view);
                    NotificationAPI.ClearNotifications();
                }
                catch (Exception)
                {
                }
            };
        }