Esempio n. 1
0
        /// <summary>
        /// Handles actions to take during the time when the splash screen is visible.
        /// </summary>
        /// <param name="sender">Automaitcally generated by Visual Studio.</param>
        /// <param name="e">Automaitcally generated by Visual Studio.</param>
        private void backgroundWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            // NOTE: Put any time-consuming tasks that only need to be done once on startup (such as file I/O) here.
            // They will be done while the splash screen is up.

            InitializeDB();

            //Set the default folders to where the application is currently running.
            DirectoryManagement.Initialise();

            // Kill any erroneous processes that may be running.
            int currentPID = Process.GetCurrentProcess().Id;

            foreach (Process p in Process.GetProcessesByName("MPAi"))
            {
                if (!(p.Id == currentPID))
                {
                    p.Kill();
                    p.WaitForExit();
                    p.Dispose();
                }
            }
        }