private void UpdateStatistics() { try { var accounting = _jobObject.GetBasicAndIoAccountingInformation(); var limits = _jobObject.GetExtendedLimitInformation(); labelGeneralActiveProcesses.Text = accounting.BasicInfo.ActiveProcesses.ToString("N0"); labelGeneralTotalProcesses.Text = accounting.BasicInfo.TotalProcesses.ToString("N0"); labelGeneralTerminatedProcesses.Text = accounting.BasicInfo.TotalTerminatedProcesses.ToString("N0"); labelTimeUserTime.Text = Utils.FormatTimeSpan(new TimeSpan(accounting.BasicInfo.TotalUserTime)); labelTimeKernelTime.Text = Utils.FormatTimeSpan(new TimeSpan(accounting.BasicInfo.TotalKernelTime)); labelTimeUserTimePeriod.Text = Utils.FormatTimeSpan(new TimeSpan(accounting.BasicInfo.ThisPeriodTotalUserTime)); labelTimeKernelTimePeriod.Text = Utils.FormatTimeSpan(new TimeSpan(accounting.BasicInfo.ThisPeriodTotalKernelTime)); labelMemoryPageFaults.Text = accounting.BasicInfo.TotalPageFaultCount.ToString("N0"); labelMemoryPeakProcessUsage.Text = Utils.FormatSize(limits.PeakProcessMemoryUsed); labelMemoryPeakJobUsage.Text = Utils.FormatSize(limits.PeakJobMemoryUsed); labelIOReads.Text = accounting.IoInfo.ReadOperationCount.ToString("N0"); labelIOReadBytes.Text = Utils.FormatSize(accounting.IoInfo.ReadTransferCount); labelIOWrites.Text = accounting.IoInfo.WriteOperationCount.ToString("N0"); labelIOWriteBytes.Text = Utils.FormatSize(accounting.IoInfo.WriteTransferCount); labelIOOther.Text = accounting.IoInfo.OtherOperationCount.ToString("N0"); labelIOOtherBytes.Text = Utils.FormatSize(accounting.IoInfo.OtherTransferCount); } catch { } }
public JobProperties(JobObjectHandle jobObject) { InitializeComponent(); listProcesses.SetTheme("explorer"); listProcesses.AddShortcuts(); listProcesses.ContextMenu = listProcesses.GetCopyMenu(); listLimits.SetTheme("explorer"); listLimits.AddShortcuts(); listLimits.ContextMenu = listLimits.GetCopyMenu(); _jobObject = jobObject; _jobObject.Reference(); timerUpdate.Interval = Settings.Instance.RefreshInterval; this.UpdateStatistics(); try { string name = _jobObject.GetObjectName(); if (string.IsNullOrEmpty(name)) { textJobName.Text = "(unnamed job)"; } else { textJobName.Text = name; } } catch { } try { foreach (int pid in _jobObject.GetProcessIdList()) { ListViewItem item = new ListViewItem(); if (Program.ProcessProvider.Dictionary.ContainsKey(pid)) { item.Text = Program.ProcessProvider.Dictionary[pid].Name; } else { item.Text = "(unknown)"; } item.SubItems.Add(new ListViewItem.ListViewSubItem(item, pid.ToString())); listProcesses.Items.Add(item); } } catch { } try { var extendedLimits = _jobObject.GetExtendedLimitInformation(); var uiRestrictions = _jobObject.GetBasicUiRestrictions(); var flags = extendedLimits.BasicLimitInformation.LimitFlags; if ((flags & JobObjectLimitFlags.ActiveProcess) != 0) { this.AddLimit("Active Processes", extendedLimits.BasicLimitInformation.ActiveProcessLimit.ToString()); } if ((flags & JobObjectLimitFlags.Affinity) != 0) { this.AddLimit("Affinity", extendedLimits.BasicLimitInformation.Affinity.ToString("x")); } if ((flags & JobObjectLimitFlags.BreakawayOk) != 0) { this.AddLimit("Breakaway OK", "Enabled"); } if ((flags & JobObjectLimitFlags.DieOnUnhandledException) != 0) { this.AddLimit("Die on Unhandled Exception", "Enabled"); } if ((flags & JobObjectLimitFlags.JobMemory) != 0) { this.AddLimit("Job Memory", Utils.FormatSize(extendedLimits.JobMemoryLimit)); } if ((flags & JobObjectLimitFlags.JobTime) != 0) { this.AddLimit("Job Time", Utils.FormatTimeSpan(new TimeSpan(extendedLimits.BasicLimitInformation.PerJobUserTimeLimit))); } if ((flags & JobObjectLimitFlags.KillOnJobClose) != 0) { this.AddLimit("Kill on Job Close", "Enabled"); } if ((flags & JobObjectLimitFlags.PriorityClass) != 0) { this.AddLimit("Priority Class", ((System.Diagnostics.ProcessPriorityClass)extendedLimits.BasicLimitInformation.PriorityClass).ToString()); } if ((flags & JobObjectLimitFlags.ProcessMemory) != 0) { this.AddLimit("Process Memory", Utils.FormatSize(extendedLimits.ProcessMemoryLimit)); } if ((flags & JobObjectLimitFlags.ProcessTime) != 0) { this.AddLimit("Process Time", Utils.FormatTimeSpan(new TimeSpan(extendedLimits.BasicLimitInformation.PerProcessUserTimeLimit))); } if ((flags & JobObjectLimitFlags.SchedulingClass) != 0) { this.AddLimit("Scheduling Class", extendedLimits.BasicLimitInformation.SchedulingClass.ToString()); } if ((flags & JobObjectLimitFlags.SilentBreakawayOk) != 0) { this.AddLimit("Silent Breakaway OK", "Enabled"); } if ((flags & JobObjectLimitFlags.WorkingSet) != 0) { this.AddLimit("Minimum Working Set", Utils.FormatSize(extendedLimits.BasicLimitInformation.MinimumWorkingSetSize)); this.AddLimit("Maximum Working Set", Utils.FormatSize(extendedLimits.BasicLimitInformation.MaximumWorkingSetSize)); } if ((uiRestrictions & JobObjectBasicUiRestrictions.Desktop) != 0) { this.AddLimit("Desktop", "Limited"); } if ((uiRestrictions & JobObjectBasicUiRestrictions.DisplaySettings) != 0) { this.AddLimit("Display Settings", "Limited"); } if ((uiRestrictions & JobObjectBasicUiRestrictions.ExitWindows) != 0) { this.AddLimit("Exit Windows", "Limited"); } if ((uiRestrictions & JobObjectBasicUiRestrictions.GlobalAtoms) != 0) { this.AddLimit("Global Atoms", "Limited"); } if ((uiRestrictions & JobObjectBasicUiRestrictions.Handles) != 0) { this.AddLimit("Handles", "Limited"); } if ((uiRestrictions & JobObjectBasicUiRestrictions.ReadClipboard) != 0) { this.AddLimit("Read Clipboard", "Limited"); } if ((uiRestrictions & JobObjectBasicUiRestrictions.SystemParameters) != 0) { this.AddLimit("System Parameters", "Limited"); } if ((uiRestrictions & JobObjectBasicUiRestrictions.WriteClipboard) != 0) { this.AddLimit("Write Clipboard", "Limited"); } } catch { } }
public JobProperties(JobObjectHandle jobObject) { InitializeComponent(); _jobObject = jobObject; _jobObject.Reference(); timerUpdate.Interval = Properties.Settings.Default.RefreshInterval; this.UpdateStatistics(); try { string name = _jobObject.GetObjectName(); if (string.IsNullOrEmpty(name)) textJobName.Text = "(unnamed job)"; else textJobName.Text = name; } catch { } try { foreach (int pid in _jobObject.GetProcessIdList()) { ListViewItem item = new ListViewItem(); if (Program.ProcessProvider.Dictionary.ContainsKey(pid)) item.Text = Program.ProcessProvider.Dictionary[pid].Name; else item.Text = "(unknown)"; item.SubItems.Add(new ListViewItem.ListViewSubItem(item, pid.ToString())); listProcesses.Items.Add(item); } } catch { } try { var extendedLimits = _jobObject.GetExtendedLimitInformation(); var uiRestrictions = _jobObject.GetBasicUiRestrictions(); var flags = extendedLimits.BasicLimitInformation.LimitFlags; if ((flags & JobObjectLimitFlags.ActiveProcess) != 0) this.AddLimit("Active Processes", extendedLimits.BasicLimitInformation.ActiveProcessLimit.ToString()); if ((flags & JobObjectLimitFlags.Affinity) != 0) this.AddLimit("Affinity", extendedLimits.BasicLimitInformation.Affinity.ToString("x")); if ((flags & JobObjectLimitFlags.BreakawayOk) != 0) this.AddLimit("Breakaway OK", "Enabled"); if ((flags & JobObjectLimitFlags.DieOnUnhandledException) != 0) this.AddLimit("Die on Unhandled Exception", "Enabled"); if ((flags & JobObjectLimitFlags.JobMemory) != 0) this.AddLimit("Job Memory", Utils.FormatSize(extendedLimits.JobMemoryLimit)); if ((flags & JobObjectLimitFlags.JobTime) != 0) this.AddLimit("Job Time", Utils.FormatTimeSpan(new TimeSpan(extendedLimits.BasicLimitInformation.PerJobUserTimeLimit))); if ((flags & JobObjectLimitFlags.KillOnJobClose) != 0) this.AddLimit("Kill on Job Close", "Enabled"); if ((flags & JobObjectLimitFlags.PriorityClass) != 0) this.AddLimit("Priority Class", ((System.Diagnostics.ProcessPriorityClass)extendedLimits.BasicLimitInformation.PriorityClass).ToString()); if ((flags & JobObjectLimitFlags.ProcessMemory) != 0) this.AddLimit("Process Memory", Utils.FormatSize(extendedLimits.ProcessMemoryLimit)); if ((flags & JobObjectLimitFlags.ProcessTime) != 0) this.AddLimit("Process Time", Utils.FormatTimeSpan(new TimeSpan(extendedLimits.BasicLimitInformation.PerProcessUserTimeLimit))); if ((flags & JobObjectLimitFlags.SchedulingClass) != 0) this.AddLimit("Scheduling Class", extendedLimits.BasicLimitInformation.SchedulingClass.ToString()); if ((flags & JobObjectLimitFlags.SilentBreakawayOk) != 0) this.AddLimit("Silent Breakaway OK", "Enabled"); if ((flags & JobObjectLimitFlags.WorkingSet) != 0) { this.AddLimit("Minimum Working Set", Utils.FormatSize(extendedLimits.BasicLimitInformation.MinimumWorkingSetSize)); this.AddLimit("Maximum Working Set", Utils.FormatSize(extendedLimits.BasicLimitInformation.MaximumWorkingSetSize)); } if ((uiRestrictions & JobObjectBasicUiRestrictions.Desktop) != 0) this.AddLimit("Desktop", "Limited"); if ((uiRestrictions & JobObjectBasicUiRestrictions.DisplaySettings) != 0) this.AddLimit("Display Settings", "Limited"); if ((uiRestrictions & JobObjectBasicUiRestrictions.ExitWindows) != 0) this.AddLimit("Exit Windows", "Limited"); if ((uiRestrictions & JobObjectBasicUiRestrictions.GlobalAtoms) != 0) this.AddLimit("Global Atoms", "Limited"); if ((uiRestrictions & JobObjectBasicUiRestrictions.Handles) != 0) this.AddLimit("Handles", "Limited"); if ((uiRestrictions & JobObjectBasicUiRestrictions.ReadClipboard) != 0) this.AddLimit("Read Clipboard", "Limited"); if ((uiRestrictions & JobObjectBasicUiRestrictions.SystemParameters) != 0) this.AddLimit("System Parameters", "Limited"); if ((uiRestrictions & JobObjectBasicUiRestrictions.WriteClipboard) != 0) this.AddLimit("Write Clipboard", "Limited"); } catch { } }