Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Process Operations (Monitoring)
- private void timer_ProcessCheck_Tick(object sender, EventArgs e)
- {
- Process[] tmpArray = Wow_getCurrentlyRunning(); // this returns Process[]
- if (comboBox_processes.Items.Count == 0)
- {
- if (tmpArray.Count() > 0)
- for (int Index = 0; Index < tmpArray.Count(); Index++)
- Add(tmpArray[Index]); // adding to combobox
- }
- else
- {
- if (tmpArray.Count() > comboBox_processes.Items.Count)
- {
- List<Process> result;
- /*Diff compares the two array, and returns to result variable.*/
- if (Diff(tmpArray, comboBox_processes, out result))
- foreach(Process proc in result)
- Add(proc); // adding to combobox
- }
- }
- }
- public bool Wow_differsFrom(Process[] current, ComboBox local, out List<Process> diff)
- {
- List<int> diffIndex = new List<int>();
- foreach (Process proc in current)
- diffIndex.Add(proc.Id);
- for (byte Índex = 0; Índex < current.Count(); Índex++)
- {
- for (byte Index = 0; Index < local.Items.Count; Index++)
- {
- if (current[Índex].Id == (local.Items[Index] as Process).Id)
- {
- diffIndex.Remove(current[Índex].Id);
- break;
- }
- }
- }
- diff = new List<Process>();
- for (int x = 0; x < current.Count(); x++)
- for (int i = 0; i < diffIndex.Count; i++)
- if (current[x].Id == diffIndex[i])
- diff.Add(current[x]);
- if (diff.Count == 0)
- return false;
- return true;
- }
- private void Wow_exitedEvent(object o, EventArgs e)
- {
- RemoveCBItem(comboBox_processes, (o as Process).Id); // this will remove the process from combobox, also threadsafe.
- }
- //Somewhere in Form_Load
- combobox.DisplayMember = "Name";//name of the property in your MyProcessInfo class
- combobox.ValueMember = "Id";//name of the property in your MyProcessInfo class
- //In your timer.Tick handler
- combobox.DataSource = Wow_getCurrentlyRunning().Select(p=>new MyProcessInfo(p.Id, p.Name)).ToList();
Add Comment
Please, Sign In to add comment