Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //https://stackoverflow.com/questions/24928472/getting-text-from-richtextbox-and-timer-to-detect-changes
- private void Form1_Load(object sender, EventArgs e)
- {
- timer1.Enabled = true;
- }
- private void running_process()
- {
- Process[] processes = Process.GetProcesses("ITWORKSPC152");
- for (int i = 0; i < listView1.Items.Count; i++)
- {
- if (flag == false)
- {
- listView1.Items[i].SubItems.Add("Inactive");
- if(i == listView1.Items.Count - 1)
- flag = true;
- }
- foreach (Process p in processes)
- {
- if (!listBox1.Items.Contains(listView1.Items[i].Text))
- {
- listView1.Items[i].SubItems[1].Text = " ";
- listView1.Items[i].SubItems[1].Text = "Inactive";
- listView1.Items[i].BackColor = Color.Red;
- }
- if (listView1.Items[i].Text == p.ProcessName)
- {
- listBox1.Items.Add(p.ProcessName);
- listView1.Items[i].SubItems[1].Text = "Inactive";
- for (int j = 0; j < listBox1.Items.Count; j++)
- {
- if (listBox1.Items[j].ToString() == listView1.Items[i].Text)
- {
- listView1.Items[i].SubItems[1].Text = "Active";
- listView1.Items[i].BackColor = Color.FromArgb(66, 181, 33);
- //m_boolIsDown = false;
- }
- }
- }
- }
- if (listView1.Items[i].SubItems[1].Text == "Inactive")
- {
- richTextBox1.Text = richTextBox1.Text + listView1.Items[i].Text + " was inactive at " + DateTime.Now.ToString("hh':'mm tt") + "\n";
- File.AppendAllText(@"C:\Documents and Settings\pamojica\My Documents\InactiveProgramLogs\DASHBOARD.txt", richTextBox1.Text);
- }
- }
- }
- private void timer1_Tick(object sender, EventArgs e)
- {
- listBox1.Items.Clear();
- richTextBox1.Clear();
- running_process();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement