示例#1
0
 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
            { }
        }
示例#3
0
        public unsafe void SetExtendedLimit(ref JobObjectExtendedLimitInformation limit)
        {
            var copy = limit;

            var result = Kernel32.SetInformationJobObject(
                mHandle,
                JobObjectInfoClass.ExtendedLimitInformation,
                &copy,
                sizeof(JobObjectExtendedLimitInformation)
                );

            if (!result)
            {
                throw new Win32Exception(Marshal.GetLastWin32Error());
            }
            limit = copy;
        }
示例#4
0
        /// <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));
            }
        }
示例#5
0
        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);
        }
示例#6
0
        /// <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));
            }
        }
示例#7
0
 public extern static bool SetInformationJobObject(IntPtr hJob, int informationClass, [In] ref JobObjectExtendedLimitInformation info, int size);
示例#8
0
 public static extern bool QueryInformationJobObject(
     IntPtr hJob,
     int query,
     out JobObjectExtendedLimitInformation info,
     int size,
     out int returnedSize
     );