コード例 #1
0
 private void Quit()
 {
     if (MessageBox.Show("The program is going to quit, all the connections will be shutdown.\nConfirm?", "Closing Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
     {
         for (int k = 0; k < 4; k++)
         {
             _sp[k].DisconnectionReq();
         }
         eThread.Abort();
         dThread.Abort();
         ClipboardFiles.FreeTmpResources();
         Application.Exit();
     }
 }
コード例 #2
0
        /// <summary>
        /// Pulire le risorse in uso.
        /// </summary>
        /// <param name="disposing">ha valore true se le risorse gestite devono essere eliminate, false in caso contrario.</param>
        protected override void Dispose(bool disposing)
        {
            // Save settings
            if (ipListBox.SelectedItem != null)
            {
                Properties.Settings.Default["IpAddress"] = ipListBox.SelectedItem.ToString();
            }
            else
            {
                Properties.Settings.Default["IpAddress"] = "";
            }
            Properties.Settings.Default["EventsPort"]    = (ushort)eventsPortUpDown.Value;
            Properties.Settings.Default["ClipboardPort"] = (ushort)clipboardUpDown.Value;
            Properties.Settings.Default["Password"]      = psswBox.Text;
            Properties.Settings.Default["Autorun"]       = autorunCheckBox.Checked;
            Properties.Settings.Default.Save();
            RegistryKey key;

            key = Registry.CurrentUser.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Run\\", true);
            if (autorunCheckBox.Checked)
            {
                key.SetValue(ProgramKeyName, "\"" + AppDomain.CurrentDomain.BaseDirectory +
                             AppDomain.CurrentDomain.FriendlyName + "\"");
            }
            else
            {
                if (key.GetValue(ProgramKeyName, null) != null)
                {
                    key.DeleteValue("PDS_Project_Server");
                }
            }
            key.Close();


            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
            if (_evtServer != null)
            {
                _evtServer.Terminate();
            }
            if (_clpbServer != null)
            {
                _clpbServer.Terminate();
            }
            _blinking.Terminate();
            ClipboardFiles.FreeTmpResources();
        }