public void UpdateProcessSelections(ObservablePlayerCollection <Player> ActiveProcessList) { while (!Globals.Exiting) { // Get current running processes named pol: var CurrentProcessList = Process.GetProcessesByName("pol").ToList(); if (CurrentProcessList.Count == 0 && ActiveProcessList.Count > 0) { //There are no POL Processes we need to handle //Clear them, Players will clean themselves up ActiveProcessList.Clear(); } else if (CurrentProcessList.Count > 0) { foreach (Process FFXI in CurrentProcessList) { // The process isn't responding, ignore it if (!FFXI.Responding) { continue; } if (!ActiveProcessList.Any(P => P.Id == FFXI.Id)) { if (FFXI.MainWindowTitle.Length == 0 || FFXI.MainWindowTitle.Contains(' ')) { continue; } // The character hasn't been added to the list yet ActiveProcessList.Add(new Player(FFXI)); HandleNewCharacter(); continue; } } foreach (Player FFXIChar in ActiveProcessList.ToList()) { if (!CurrentProcessList.Any(P => P.MainWindowTitle == FFXIChar.Name)) { FFXIChar.SaveSettings(); FFXIChar.Destroy(); ActiveProcessList.Remove(FFXIChar); } } } Thread.Sleep(100); } }
private void PyxieWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e) { Globals.Exiting = true; try { using (StreamWriter streamWriter = new StreamWriter(AppDomain.CurrentDomain.BaseDirectory + "\\Pyxie.xml")) { var serializer = new XmlSerializer(typeof(Configuration)); serializer.Serialize(streamWriter, Globals.Instance.Pyxie); } } catch (Exception ex) { MessageBox.Show("Pyxie was unable to save your global configuration file:\r\n\r\n" + ex.ToString()); } foreach (Player FFXIChar in ActiveProcessList) { FFXIChar.SaveSettings(); } Thread.Sleep(150); }