How do i find the highest lowest and average numbers when im closing the Form/Program and also each X minutes?
<p>For now i will pass the X minutes i will not doing it for now.
For the rest this is the code im using now.</p>

<p>I tried to do it this way:</p>

<pre><code>using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
using DannyGeneral;
namespace CpuUsage
{
    public partial class Form1 : Form
    {
        private PerformanceCounter theCPUCounter;
        private PerformanceCounter theMemCounter;
        private PerformanceCounter specProcessCPUCounter;
        private float cpuUsage;
        private float memUsage;
        private string processname;
        private List&lt;float&gt; Values;
        public Form1()
        {
            InitializeComponent();
            Values = new List&lt;float&gt;();
                theCPUCounter = new PerformanceCounter("Processor", "% Processor Time", "_Total");
                theMemCounter = new PerformanceCounter("Memory", "Available MBytes");
                specProcessCPUCounter = new PerformanceCounter("Process", "% Processor Time", Process.GetCurrentProcess().ProcessName);


        }
        private void Form1_Load(object sender, EventArgs e)
        {
        }
        private void timer1_Tick(object sender, EventArgs e)
        {
            memUsage = theMemCounter.NextValue();
            label1.Text = memUsage.ToString();
            Logger.Write("Memory Usage   " + memUsage.ToString());
            cpuUsage = this.theCPUCounter.NextValue();
            label2.Text = cpuUsage.ToString();
            Logger.Write("Cpu Usage   " + this.cpuUsage.ToString());
            Values.Add(cpuUsage);
        }
        private void Form1_FormClosing(object sender, FormClosingEventArgs e)
        {

            float Maximum = Values.Max();
            float Minimum = Values.Min();
            float Average = Values.Average();
            string t = string.Format("{0}Maximum,{1}Minimum,{2}Average", Maximum, Minimum, Average);
            Logger.Write(t);
        }
    }
}
</code></pre>

<p>The problem is that the result in the logger text file is like this:</p>

<pre><code>8/29/2012--1:57 AM ==&gt; Memory Usage   2683
8/29/2012--1:57 AM ==&gt; Cpu Usage   0
8/29/2012--1:57 AM ==&gt; Memory Usage   2681
8/29/2012--1:57 AM ==&gt; Cpu Usage   5.951914
8/29/2012--1:57 AM ==&gt; Memory Usage   2675
8/29/2012--1:57 AM ==&gt; Cpu Usage   1.15339
8/29/2012--1:57 AM ==&gt; Memory Usage   2674
8/29/2012--1:57 AM ==&gt; Cpu Usage   4.230328
8/29/2012--1:57 AM ==&gt; Memory Usage   2674
8/29/2012--1:57 AM ==&gt; Cpu Usage   1.345688
8/29/2012--1:57 AM ==&gt; Memory Usage   2677
8/29/2012--1:57 AM ==&gt; Cpu Usage   4.422635
8/29/2012--1:57 AM ==&gt; Memory Usage   2676
8/29/2012--1:57 AM ==&gt; Cpu Usage   0.768766
8/29/2012--1:57 AM ==&gt; Memory Usage   2676
8/29/2012--1:57 AM ==&gt; Cpu Usage   0.5764585
8/29/2012--1:57 AM ==&gt; Memory Usage   2676
8/29/2012--1:57 AM ==&gt; Cpu Usage   8.076494
8/29/2012--1:58 AM ==&gt; 8.076494Maximum,0Minimum,2.947297Average
</code></pre>

<p>The last line the Format is not like i wanted it to be.
I wanted it to be something like: Maximum --- 8.076494 , Minimum --- 0 , Average --- 2.947297</p>

<p>But now im getting first the values then the text and without spaces between the values and each text.</p>

<p>My only problem now is the last line the string.Format</p>

<p>About every 5 minutes i will pass it for now will not doing it now.</p>
