在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
定义获取指示进程的用户界面当前是否响应的值。 获取指示进程的用户界面当前是否响应的值。
属性值false。 异常false,以在 Windows 98 和 Windows Me 上访问此属性。 Process 对象关联的进程。 此属性仅可用于本地计算机上运行的进程。 示例该示例检测时在进程退出,并显示该进程的退出代码。 using System; using System.Diagnostics; namespace ProcessSample { class ProcessMonitorSample { public static void Main() { // Define variables to track the peak // memory usage of the process. long peakPagedMem = 0, peakWorkingSet = 0, peakVirtualMem = 0; // Start the process. using (Process myProcess = Process.Start("NotePad.exe")) { // Display the process statistics until // the user closes the program. do { if (!myProcess.HasExited) { // Refresh the current process property values. myProcess.Refresh(); Console.WriteLine(); // Display current process statistics. Console.WriteLine($"{myProcess} -"); Console.WriteLine("-------------------------------------"); Console.WriteLine($" Physical memory usage : {myProcess.WorkingSet64}"); 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($" Paged system memory size : {myProcess.PagedSystemMemorySize64}"); Console.WriteLine($" Paged memory size : {myProcess.PagedMemorySize64}"); // Update the values for the overall peak memory statistics. peakPagedMem = myProcess.PeakPagedMemorySize64; peakVirtualMem = myProcess.PeakVirtualMemorySize64; peakWorkingSet = myProcess.PeakWorkingSet64; if (myProcess.Responding) { Console.WriteLine("Status = Running"); } else { Console.WriteLine("Status = Not Responding"); } } } while (!myProcess.WaitForExit(1000)); Console.WriteLine(); Console.WriteLine($" Process exit code : {myProcess.ExitCode}"); // Display peak memory statistics for the process. Console.WriteLine($" Peak physical memory usage : {peakWorkingSet}"); Console.WriteLine($" Peak paged memory usage : {peakPagedMem}"); Console.WriteLine($" Peak virtual memory usage : {peakVirtualMem}"); } } } }
注解使用此属性确定关联的进程的界面已停止响应。 MainWindowHandle,此属性返回 应用示例1 public static void Main(string[] args) 2 { 3 Process[] process = Process.GetProcessesByName("应用程序进程名"); 4 5 if (process.Length > 0) 6 { 7 Process myProcess = process[0]; 8 9 do 10 { 11 if (!myProcess.HasExited) 12 { 13 myProcess.Refresh(); 14 if (myProcess.Responding) 15 { 16 //Console.WriteLine("Status = Running"); 17 } 18 else 19 { 20 //Console.WriteLine("Status = Not Responding"); 21 //无响应处理过程。。。。 22 23 } 24 } 25 } 26 while (!myProcess.WaitForExit(ReadWatchTime())); 27 } 28 }
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论