» »

prikaz porabe proc na win formi

prikaz porabe proc na win formi

Lualah ::

Uporabil sem http://www.dotnetspider.com/resources/4...

ampak porabe proca ne kaže, ram dela, proc pa ne. Mogoče ima kdo idejo zakaj je vedno 0% procesor. Uporabljam VS 2008.

Senzacionale ::

napačna uporaba poglej na link kako ej tu narejeno, v init daj..

http://www.gamedev.net/community/forums...
http://www.dostavahrane.si

Ericssony ::

Dodaš Timer in zadeva deluje...

public partial class Form1 : Form
    {
        System.Diagnostics.PerformanceCounter cpuCounter;
        System.Diagnostics.PerformanceCounter ramCounter;

        readonly System.Timers.Timer updateCpu = new System.Timers.Timer(1000);

        public Form1()
        {
            InitializeComponent();

            updateCpu.Elapsed += UpdateCpuElapsed;
            updateCpu.Start();
        }

        private void UpdateCpuElapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            Invoke(new MethodInvoker(UpdateCpuUsage));
        }

        private void UpdateCpuUsage()
        {
            label1.Text = GetCurrentCpuUsage();
            label2.Text = GetAvailableRam();
        }


        private void Form1_Load(object sender, EventArgs e)
        {
            // Put into page load
            cpuCounter = new System.Diagnostics.PerformanceCounter
                             {
                                 CategoryName = "Processor",
                                 CounterName = "% Processor Time",
                                 InstanceName = "_Total"
                             };

            ramCounter = new System.Diagnostics.PerformanceCounter("Memory", "Available MBytes");
        }

        // Call this method every time you need to know the current cpu usage. 
        public string GetCurrentCpuUsage()
        {
            return cpuCounter.NextValue() + "%";
        }

        // Call this method every time you need to get the amount of the available RAM in Mb 
        public string GetAvailableRam()
        {
            return ramCounter.NextValue() + "Mb";
        }					
    }

Lualah ::

Hvala obema, urejeno sedaj deluje kot treba. Imam pa še en problem. Send and receive data deluje na visti, na win 2003 mašini pa je ves čas 1kb, je lahko problem v "instance" ki je mrežna naprava, in ima win 2003 drugačno kot vista?

PerformanceCounterCategory performanceCounterCategory = new PerformanceCounterCategory("Network Interface");
         
// 1st NIC !
string instance = performanceCounterCategory.GetInstanceNames()[0];

counterSent = new PerformanceCounter("Network Interface", "Bytes Sent/sec", instance);
counterReceived = new PerformanceCounter("Network Interface", "Bytes Received/sec", instance);

Zgodovina sprememb…

  • spremenilo: Lualah ()


Vredno ogleda ...

TemaSporočilaOglediZadnje sporočilo
TemaSporočilaOglediZadnje sporočilo
»

C# osveževanje app

Oddelek: Programiranje
12935 (705) mihies
»

Problem z ramom ali diskom? Prosim za nasvet.

Oddelek: Strojna oprema
111096 (998) Duhec
»

c# datagridview in combox

Oddelek: Programiranje
131197 (1085) OmegaM
»

Valve & STEAM & On-Line gaming (strani: 1 2 )

Oddelek: Igre
718217 (6639) Tilen
»

c++ čas izvajanja ukaza

Oddelek: Programiranje
161276 (1124) fogl

Več podobnih tem