Пример #1
0
 public int GetGpuLoad()
 {
     try
     {
         return(NvGpuLoad.GetGpuLoad());
     }
     catch (DllNotFoundException e)
     {
         return(0);
     }
 }
Пример #2
0
 public static int GetGPUValue()
 {
     try
     {
         return(NvGpuLoad.GetGpuLoad());
     }
     catch
     {
         // probably no NVidia GPU is present so close the thread
         return(-1);
     }
 }
Пример #3
0
        void GetDATA()
        {
            float fcpu = CPU.NextValue();

            label1.Text = string.Format("{0:0.00}%", fcpu);

            progressBar1.Value = (int)fcpu;

            float fgpu = NvGpuLoad.GetGpuLoad();

            //try
            //{
            //    fgpu = NvGpuLoad.GetGpuLoad();
            //}
            //catch (DllNotFoundException e)
            //{
            //    MessageBox.Show("!");
            //}
            label2.Text        = string.Format("{0:0.00}%", fgpu);
            progressBar2.Value = (int)fgpu;
        }
Пример #4
0
 // fetches the GPU counter using the NVidia API wrapper
 // code from https://github.com/coraxx/CpuGpuGraph
 // originally inspired from https://eliang.blogspot.com/2011/05/getting-nvidia-gpu-usage-in-c.html
 void FetchGPUCounter(object o)
 {
     while (true)
     {
         try
         {
             // send the GPU usage
             DateTime time = DateTime.Now;
             ParseData(new SEvent(59, time, "global GPU usage", "global", EventType.SINGLE, new string[] { "value" }, new string[] { NvGpuLoad.GetGpuLoad().ToString() }));
             Thread.Sleep(samplingTime);
         }
         catch
         {
             // probably no NVidia GPU is present so close the thread
             //TODO should be managed in a more elegant way
             Thread.CurrentThread.Abort();
         }
     }
 }