當前位置: 首頁>>代碼示例>>C#>>正文


C# Process.WorkingSet屬性代碼示例

本文整理匯總了C#中System.Diagnostics.Process.WorkingSet屬性的典型用法代碼示例。如果您正苦於以下問題:C# Process.WorkingSet屬性的具體用法?C# Process.WorkingSet怎麽用?C# Process.WorkingSet使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在System.Diagnostics.Process的用法示例。


在下文中一共展示了Process.WorkingSet屬性的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Main

//引入命名空間
using System;
using System.Diagnostics;
using System.Threading;

namespace ProcessSample
{
    class MyProcessClass
    {
        public static void Main()
        {
            try
            {
                using (Process myProcess = Process.Start("NotePad.exe"))
                {
                    while (!myProcess.HasExited)
                    {
                        Console.WriteLine();

                        Console.WriteLine($"Physical memory usage     : {myProcess.WorkingSet}");
                        Console.WriteLine($"Base priority             : {myProcess.BasePriority}");
                        Console.WriteLine($"Priority class            : {myProcess.PriorityClass}");
                        Console.WriteLine($"User processor time       : {myProcess.UserProcessorTime}");
                        Console.WriteLine($"Privileged processor time : {myProcess.PrivilegedProcessorTime}");
                        Console.WriteLine($"Total processor time      : {myProcess.TotalProcessorTime}");
                        Console.WriteLine($"Process's Name            : {myProcess}");
                        Console.WriteLine("-------------------------------------");

                        if (myProcess.Responding)
                        {
                            Console.WriteLine("Status:  Responding to user interface");
                            myProcess.Refresh();
                        }
                        else
                        {
                            Console.WriteLine("Status:  Not Responding");
                        }

                        Thread.Sleep(1000);
                    }

                    Console.WriteLine();
                    Console.WriteLine($"Process exit code: {myProcess.ExitCode}");
                }
            }
            catch (Exception e)
            {
                Console.WriteLine($"The following exception was raised: {e.Message}");
            }
        }
    }
}
開發者ID:.NET開發者,項目名稱:System.Diagnostics,代碼行數:52,代碼來源:Process.WorkingSet

示例2: Main

//引入命名空間
using System;
using System.Diagnostics;

class MainClass
{
   public static void Main()
   {
      Process thisProc = Process.GetCurrentProcess();
      Console.WriteLine("ProcessName:"+ thisProc.ProcessName);
      Console.WriteLine("Process: {0}, ID: {1}", thisProc.StartTime, thisProc.Id);
      Console.WriteLine("    CPU time: {0}", thisProc.TotalProcessorTime);
      Console.WriteLine("    priority class: {0}  priority: {1}", thisProc.PriorityClass, thisProc.BasePriority);
      Console.WriteLine("    virtual memory: {0}", thisProc.VirtualMemorySize);
      Console.WriteLine("    private memory: {0}", thisProc.PrivateMemorySize);
      Console.WriteLine("    physical memory: {0}", thisProc.WorkingSet);

   }
}
開發者ID:C#程序員,項目名稱:System.Diagnostics,代碼行數:19,代碼來源:Process.WorkingSet


注:本文中的System.Diagnostics.Process.WorkingSet屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。