Identify the largest number

Asked

Viewed 171 times

0

I’m making a resource monitoring software and I’m having trouble getting it to identify the largest number.

public string max()
    {

        System.Diagnostics.Process[] ieProcs = Process.GetProcessesByName("devenv");
        double avvv = 0;
        string abi = null;
        if (ieProcs.Length > 0)
        {
            foreach (System.Diagnostics.Process p in ieProcs)
            {

                String virtualMem = p.VirtualMemorySize64.ToString();
                String physicalMem = p.WorkingSet64.ToString();
                String cpu = p.TotalProcessorTime.ToString();
                abi = physicalMem;
            }
        }

        avvv = double.Parse(abi);
        avvv = avvv * 0.001 / 1024;
        return avvv.ToString();
    }

above the code I would like to capture the largest number, this is a code that monitors the use of ram memory of the process, just like does the Windows task manager, only I want to get the peak at the time when the process uses the largest contity of ram memory. The values are dynamic and whenever it changes to a higher one I want it to change to the maximum value.

That way I’d like him to show off.

  • Behold this

  • It seems logical to compare the next foreach value with the previous result and update the textbox if the new value is higher. You can take this test?

1 answer

0

See if this solves:

private static double Max_avvv=0;
public string max()
{

    System.Diagnostics.Process[] ieProcs = Process.GetProcessesByName("devenv");
    double avvv = 0;
    string abi = null;
    if (ieProcs.Length > 0)
    {
        foreach (System.Diagnostics.Process p in ieProcs)
        {

            String virtualMem = p.VirtualMemorySize64.ToString();
            String physicalMem = p.WorkingSet64.ToString();
            String cpu = p.TotalProcessorTime.ToString();
            abi = physicalMem;
        }
    }

    avvv = double.Parse(abi);
    avvv = avvv * 0.001 / 1024;

    if(Max_avvv<avvv)
       Max_avvv=avvv;

    return Max_avvv.ToString();
}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.