Dispose() protected method

Clean up any resources being used.
protected Dispose ( bool disposing ) : void
disposing bool true if managed resources should be disposed; otherwise, false.
return void
Example #1
0
        private void Shutdown()
        {
            if (CanShutdown)
            {
                ShutdownTimer.Enabled = true;
                ShutdownNotification shut = new ShutdownNotification {ShutdownType = GetShutdownType()};

                switch (shut.ShowDialog(this))
                {
                    case DialogResult.Cancel:
                        ShutdownTimer.Enabled = false;
                        MessageBox.Show(GetShutdownType() + " aborted!");
                        break;
                    case DialogResult.Yes:
                        if (GetShutdownType() == "Standby" || GetShutdownType() == "Hibernate")
                        {
                            shut.Close();
                            shut.Dispose();
                            ShutdownTimer.Enabled = false;
                        }
                        break;
                }
                ShutdownComputer();
            }
        }
Example #2
0
        private void CanShutdown()
        {
            if (chkShutdown.Checked && listMaker.Count == 0)
            {
                ShutdownTimer.Enabled = true;
                ShutdownNotification shut = new ShutdownNotification();
                shut.ShutdownType = GetShutdownType();

                DialogResult result = shut.ShowDialog(this);

                if (result == DialogResult.Cancel)
                {
                    ShutdownTimer.Enabled = false;
                    MessageBox.Show(GetShutdownType() + " aborted!");
                }
                else if (result == DialogResult.Yes)
                    if (GetShutdownType() == "Standby" || GetShutdownType() == "Hibernate")
                    {
                        shut.Close();
                        shut.Dispose();
                        ShutdownTimer.Enabled = false;
                    }
                ShutdownComputer();
            }
        }