示例#1
0
 private void SetCloseClass()
 {
     if (this.label2.InvokeRequired)
     {
         SetTextCallback3 d = new SetTextCallback3(SetCloseClass);
         this.Invoke(d, new object[] { });
     }
     else
     {
         l.Add("Checked, the class is CLOSED");
     }
 }
示例#2
0
 private void AddLvItem(ListViewItem i, ListView l)
 {
     if (l.InvokeRequired)
     {
         SetTextCallback3 d = new SetTextCallback3(AddLvItem);
         this.Invoke(d, new object[] { i, l });
     }
     else
     {
         l.Items.Add(i);
     }
 }
示例#3
0
        /// <summary>
        /// metodo auxiliar para actualizar interfaz de usuario.
        /// verifica si fue invocada por otro thread y de ser asi obtiene la firma del thread de de UX y se invoca a si mismo por medio del delegate
        /// actualiza grafica y labels necesarios
        /// </summary>
        /// <param name="text"></param>
        private void SetNetIns(Double text)
        {
            if (this.groupBox7.InvokeRequired)
            {   //se intento asignar desde thread distinto.
                //invocar por medio de delegate
                SetTextCallback3 d = new SetTextCallback3(SetNetIns);
                if (!this.IsDisposed)
                {
                    try
                    {
                        this.Invoke(d, new object[] { text });
                    }
                    catch (Exception ex)
                    {
                        //se intento invocar metodo en vista cuando esta ya habia sido recolectada por GC
                        //Console.WriteLine(ex);
                    }
                }
            }
            else
            {
                //debug
                //if (text != 0)
                //{
                //    this.chartNetIn.Series["Series1"].Points.AddY(text);
                //    MessageBox.Show(text.ToString());
                //}

                this.groupBox7.Text = "Network In: " + text.ToString() + "B/sec";
                try
                {
                    if (this.chartNetIn.Series["Series1"].Points.Count >= 30)
                    {
                        this.chartNetIn.Series["Series1"].Points.RemoveAt(0);
                        this.chartNetIn.Series["Series1"].Points.Add(text);
                    }
                    else
                    {
                        this.chartNetIn.Series["Series1"].Points.Add(text);
                    }
                }
                catch (Exception e)
                {
                    //Console.WriteLine(e);
                }
            }
        }
示例#4
0
 /// <summary>
 /// metodo auxiliar para actualizar interfaz de usuario.
 /// verifica si fue invocada por otro thread y de ser asi obtiene la firma del thread de de UX y se invoca a si mismo por medio del delegate
 /// actualiza grafica y labels necesarios
 /// </summary>
 /// <param name="text"></param>
 private void SetDiskReads(Double text)
 {
     if (this.groupBox6.InvokeRequired)
     {   //se intento asignar desde thread distinto.
         //invocar por medio de delegate
         SetTextCallback3 d = new SetTextCallback3(SetDiskReads);
         if (!this.IsDisposed)
         {
             try
             {
                 this.Invoke(d, new object[] { text });
             }
             catch (Exception e)
             {
                 //se intento invocar metodo en vista cuando esta ya habia sido recolectada por GC
                 //Console.WriteLine(e);
             }
         }
     }
     else
     {
         this.groupBox6.Text = "Disk Reads: " + text.ToString() + "B/sec";
         try
         {
             if (this.chartDiskReads.Series["Series1"].Points.Count >= 30)
             {
                 this.chartDiskReads.Series["Series1"].Points.RemoveAt(0);
                 this.chartDiskReads.Series["Series1"].Points.AddY(text);
             }
             else
             {
                 this.chartDiskReads.Series["Series1"].Points.AddY(text);
             }
         }
         catch (Exception e)
         {
             //Console.WriteLine(e);
         }
     }
 }
示例#5
0
        /// <summary>
        /// metodo auxiliar para actualizar interfaz de usuario.
        /// verifica si fue invocada por otro thread y de ser asi obtiene la firma del thread de de UX y se invoca a si mismo por medio del delegate
        /// actualiza grafica y labels necesarios
        /// </summary>
        /// <param name="text"></param>
        private void SetCpuUsage(Double value)
        {
            if (this.label1.InvokeRequired)
            {   //se intento asignar desde thread distinto.
                //invocar por medio de delegate
                SetTextCallback3 d = new SetTextCallback3(SetCpuUsage);
                if (!this.IsDisposed)
                {
                    try
                    {
                        this.Invoke(d, new object[] { value });
                    }
                    catch (Exception ex)
                    {
                        //Console.WriteLine(ex);
                        //se intento invocar metodo en vista cuando esta ya habia sido recolectada por GC
                    }
                }
            }
            else
            {
                try
                {
                    this.label1.Text = "CPU Load: " + value.ToString() + "%";

                    if (this.chartCpuActual.Series["CPU"].Points.Count > 1)
                    {
                        this.chartCpuActual.Series["CPU"].Points.RemoveAt(0);
                    }
                    this.chartCpuActual.Series["CPU"].Points.Add(value);



                    #region Color Barra
                    if (value > 66)
                    {
                        this.chartCpuActual.Series[0].Color = Color.Red;
                    }
                    else if (value > 33)
                    {
                        this.chartCpuActual.Series[0].Color = Color.Orange;
                    }
                    else
                    {
                        this.chartCpuActual.Series[0].Color = Color.Green;
                    }
                    #endregion

                    if (this.chartCpuHistory.Series["CPU History"].Points.Count >= 30)
                    {
                        this.chartCpuHistory.Series["CPU History"].Points.RemoveAt(0);
                        this.chartCpuHistory.Series["CPU History"].Points.AddY(value);
                    }
                    else
                    {
                        this.chartCpuHistory.Series["CPU History"].Points.AddY(value);
                    }
                }
                catch (Exception e)
                {
                    //Console.WriteLine(e);
                }
            }
        }