public extern static bool QueryInformationJobObject( IntPtr hJob, int query, out JobObjectExtendedLimitInformation info, int size, out int returnedSize );
private void UpdateStatistics() { try { JobObjectBasicAndIoAccountingInformation accounting = _jobObject.GetBasicAndIoAccountingInformation(); JobObjectExtendedLimitInformation limits = _jobObject.ExtendedLimitInformation; 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 unsafe void SetExtendedLimit(ref JobObjectExtendedLimitInformation limit) { var copy = limit; var result = Kernel32.SetInformationJobObject( mHandle, JobObjectInfoClass.ExtendedLimitInformation, ©, sizeof(JobObjectExtendedLimitInformation) ); if (!result) { throw new Win32Exception(Marshal.GetLastWin32Error()); } limit = copy; }
/// <summary> /// Initializes a new instance of the <see cref="DatasetTrackingJob"/> class. /// </summary> public DatasetTrackingJob() { m_Handle = CreateJobObject(IntPtr.Zero, "Apollo"); if (m_Handle == IntPtr.Zero) { var error = Marshal.GetLastWin32Error(); throw new UnableToCreateJobException( string.Format( CultureInfo.InvariantCulture, "Unable to create job object. Error: {0}", error)); } var info = new JobObjectBasicLimitInformation { LimitFlags = JobObjectLimitKillOnJobClose }; var extendedInfo = new JobObjectExtendedLimitInformation { BasicLimitInformation = info }; int length = Marshal.SizeOf(typeof(JobObjectExtendedLimitInformation)); var extendedInfoPtr = Marshal.AllocHGlobal(length); Marshal.StructureToPtr(extendedInfo, extendedInfoPtr, false); if (!SetInformationJobObject( m_Handle, JobObjectInfoType.ExtendedLimitInformation, extendedInfoPtr, (uint)length)) { var error = Marshal.GetLastWin32Error(); throw new UnableToSetJobException( string.Format( CultureInfo.InvariantCulture, "Unable to set information. Error: {0}", error)); } }
public JobObject Build() { var jobObject = new JobObject(); var lim = new JobObjectExtendedLimitInformation { BasicLimitInformation = new JobObjectBasicLimitInformation { LimitFlags = LimitFlag, ActiveProcessLimit = ProcessCounts, PerProcessUserTimeLimit = UserTimeLimit, }, ProcessMemoryLimit = new UIntPtr(ProcessMemoryLimit), }; jobObject.SetExtendedLimit(ref lim); jobObject.SetUIRestrictions(LimitFunction); return(jobObject); }
public extern static bool SetInformationJobObject(IntPtr hJob, int informationClass, [In] ref JobObjectExtendedLimitInformation info, int size);
public static extern bool QueryInformationJobObject( IntPtr hJob, int query, out JobObjectExtendedLimitInformation info, int size, out int returnedSize );