public JobObject(string jobObjectName)
        {
            if (string.IsNullOrEmpty(jobObjectName))
            {
                jobObjectName = null;
            }

            this.name = jobObjectName;

            this.jobHandle = NativeMethods.CreateJobObject(IntPtr.Zero, jobObjectName);
            if (this.jobHandle.IsInvalid)
            {
                if (jobObjectName == null)
                {
                    int error = Marshal.GetLastWin32Error();
                    throw new Win32Exception(error, "CreateJobObject failed.");
                }
                else
                {
                    // JOB_OBJECT_ALL_ACCESS = 0x1F001F
                    this.jobHandle = NativeMethods.OpenJobObject(0x1F001F, false, jobObjectName);
                    if (this.jobHandle.IsInvalid)
                    {
                        int error = Marshal.GetLastWin32Error();
                        throw new Win32Exception(error, "OpenJobObject failed.");
                    }
                }
            }

            this.UpdateExtendedLimit();
        }
Exemple #2
0
 public static extern bool TerminateJobObject(JobObjectHandle hJob, uint uExitCode);
Exemple #3
0
 public static extern bool AssignProcessToJobObject(JobObjectHandle hJob, IntPtr hProcess);
Exemple #4
0
 public static extern bool QueryInformationJobObject(JobObjectHandle hJob, JobObjectInfoClass JobObjectInformationClass, IntPtr lpJobObjectInfo, uint cbJobObjectInfoLength, IntPtr lpReturnLength);
Exemple #5
0
 public static extern bool SetInformationJobObject(JobObjectHandle hJob, JobObjectInfoClass JobObjectInfoClass, IntPtr lpJobObjectInfo, uint cbJobObjectInfoLength);
Exemple #6
0
 public static extern bool IsProcessInJob(IntPtr Process, JobObjectHandle hJob, [MarshalAs(UnmanagedType.Bool)] out bool Result);
        public JobObject(string jobObjectName)
        {
            if (string.IsNullOrEmpty(jobObjectName))
            {
                jobObjectName = null;
            }

            this.name = jobObjectName;

            this.jobHandle = NativeMethods.CreateJobObject(IntPtr.Zero, jobObjectName);
            if (this.jobHandle.IsInvalid)
            {
                if (jobObjectName == null)
                {
                    int error = Marshal.GetLastWin32Error();
                    throw new Win32Exception(error, "CreateJobObject failed.");
                }
                else
                {
                    // JOB_OBJECT_ALL_ACCESS = 0x1F001F
                    this.jobHandle = NativeMethods.OpenJobObject(0x1F001F, false, jobObjectName);
                    if (this.jobHandle.IsInvalid)
                    {
                        int error = Marshal.GetLastWin32Error();
                        throw new Win32Exception(error, "OpenJobObject failed.");
                    }
                }
            }

            this.UpdateExtendedLimit();
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="JobObject"/> class. No Windows Job Object is created.
 /// </summary>
 private JobObject(JobObjectHandle jobObject, string jobObjectName)
 {
     this.jobHandle = jobObject;
     this.name = jobObjectName;
 }
 public static extern bool TerminateJobObject(JobObjectHandle hJob, uint uExitCode);
 public static extern bool AssignProcessToJobObject(JobObjectHandle hJob, IntPtr hProcess);
 public static extern bool QueryInformationJobObject(JobObjectHandle hJob, JobObjectInfoClass JobObjectInformationClass, IntPtr lpJobObjectInfo, uint cbJobObjectInfoLength, IntPtr lpReturnLength);
 public static extern bool SetInformationJobObject(JobObjectHandle hJob, JobObjectInfoClass JobObjectInfoClass, IntPtr lpJobObjectInfo, uint cbJobObjectInfoLength);
 public static extern bool IsProcessInJob(IntPtr Process, JobObjectHandle hJob, [MarshalAs(UnmanagedType.Bool)] out bool Result);
 /// <summary>
 /// Initializes a new instance of the <see cref="JobObject"/> class. No Windows Job Object is created.
 /// </summary>
 private JobObject(JobObjectHandle jobObject, string jobObjectName)
 {
     this.jobHandle = jobObject;
     this.name      = jobObjectName;
 }