当前位置: 首页>>代码示例>>C#>>正文


C# ProcessHandle.GetCycleTime方法代码示例

本文整理汇总了C#中ProcessHandle.GetCycleTime方法的典型用法代码示例。如果您正苦于以下问题:C# ProcessHandle.GetCycleTime方法的具体用法?C# ProcessHandle.GetCycleTime怎么用?C# ProcessHandle.GetCycleTime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ProcessHandle的用法示例。


在下文中一共展示了ProcessHandle.GetCycleTime方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: UpdateStatistics

        public void UpdateStatistics()
        {
            if (!Program.ProcessProvider.Dictionary.ContainsKey(_pid))
                return;

            ProcessItem item = Program.ProcessProvider.Dictionary[_pid];

            labelCPUPriority.Text = item.Process.BasePriority.ToString();
            labelCPUKernelTime.Text = Utils.FormatTimeSpan(new TimeSpan(item.Process.KernelTime));
            labelCPUUserTime.Text = Utils.FormatTimeSpan(new TimeSpan(item.Process.UserTime));
            labelCPUTotalTime.Text = Utils.FormatTimeSpan(new TimeSpan(item.Process.KernelTime + item.Process.UserTime));

            labelMemoryPB.Text = Utils.FormatSize(item.Process.VirtualMemoryCounters.PrivatePageCount);
            labelMemoryWS.Text = Utils.FormatSize(item.Process.VirtualMemoryCounters.WorkingSetSize);
            labelMemoryPWS.Text = Utils.FormatSize(item.Process.VirtualMemoryCounters.PeakWorkingSetSize);
            labelMemoryVS.Text = Utils.FormatSize(item.Process.VirtualMemoryCounters.VirtualSize);
            labelMemoryPVS.Text = Utils.FormatSize(item.Process.VirtualMemoryCounters.PeakVirtualSize);
            labelMemoryPU.Text = Utils.FormatSize(item.Process.VirtualMemoryCounters.PagefileUsage);
            labelMemoryPPU.Text = Utils.FormatSize(item.Process.VirtualMemoryCounters.PeakPagefileUsage);
            labelMemoryPF.Text = ((ulong)item.Process.VirtualMemoryCounters.PageFaultCount).ToString("N0");

            labelIOReads.Text = ((ulong)item.Process.IoCounters.ReadOperationCount).ToString("N0");
            labelIOReadBytes.Text = Utils.FormatSize(item.Process.IoCounters.ReadTransferCount);
            labelIOWrites.Text = ((ulong)item.Process.IoCounters.WriteOperationCount).ToString("N0");
            labelIOWriteBytes.Text = Utils.FormatSize(item.Process.IoCounters.WriteTransferCount);
            labelIOOther.Text = ((ulong)item.Process.IoCounters.OtherOperationCount).ToString("N0");
            labelIOOtherBytes.Text = Utils.FormatSize(item.Process.IoCounters.OtherTransferCount);

            labelOtherHandles.Text = ((ulong)item.Process.HandleCount).ToString("N0");

            if (_pid > 0)
            {
                try
                {
                    using (var phandle = new ProcessHandle(_pid, Program.MinProcessQueryRights))
                    {
                        labelOtherGDIHandles.Text = phandle.GetGuiResources(false).ToString("N0");
                        labelOtherUSERHandles.Text = phandle.GetGuiResources(true).ToString("N0");

                        if (OSVersion.HasCycleTime)
                            labelCPUCycles.Text = phandle.GetCycleTime().ToString("N0");
                        else
                            labelCPUCycles.Text = "N/A";

                        if (OSVersion.IsAboveOrEqual(WindowsVersion.Vista))
                        {
                            labelMemoryPP.Text = phandle.GetPagePriority().ToString();
                            labelIOPriority.Text = phandle.GetIoPriority().ToString();
                        }
                    }
                }
                catch
                { }
            }
            else
            {
                labelOtherGDIHandles.Text = "0";
                labelOtherUSERHandles.Text = "0";
                labelCPUCycles.Text = "0";
                labelMemoryPP.Text = "0";
                labelIOPriority.Text = "0";
            }
        }
开发者ID:RoDaniel,项目名称:featurehouse,代码行数:63,代码来源:ProcessStatistics.cs


注:本文中的ProcessHandle.GetCycleTime方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。