//3. Implement the constructor of the Job class, that accepts a string called “name” public Job(string name) { /* a. Call NativeJob.CreateJobObject passing IntPtr.Zero * and the name argument. * Store the returning handle in _hJob */ _hJob = NativeJob.CreateJobObject(IntPtr.Zero, name); //b. If the handle is zero (IntPtr.Zero), // throw an InvalidOperationException if (_hJob == IntPtr.Zero) { throw new InvalidOperationException("IntPtr is zero"); } if (_processes == null) { _processes = new List <Process>(); } //c. Create the _processes object _processes = new List <Process>(); //b. Add a call in the Job ctor to GC.AddMemoryPressure(sizeInByte) // and display a message that the Job was created GC.AddMemoryPressure(_sizeInBytes); Console.WriteLine($"job {name} created"); }
private void InitJob(string name) { _hJob = NativeJob.CreateJobObject(IntPtr.Zero, name); _processes = new List <Process>(); if (_hJob == IntPtr.Zero) { throw new InvalidOperationException("The job not created!"); } }
public Job(string name) { _hJob = NativeJob.CreateJobObject(IntPtr.Zero, name); if (_hJob == IntPtr.Zero) { throw new InvalidOperationException("can't create job"); } _processes = new List <Process>(); }
public Job(string name) { _hJob = NativeJob.CreateJobObject(IntPtr.Zero, name); if (_hJob == IntPtr.Zero) { throw new InvalidOperationException(); } _processes = new List <Process>(); _disposed = false; }
public Job(string name) { _hJob = NativeJob.CreateJobObject(IntPtr.Zero, name); if (_hJob == IntPtr.Zero) { throw new InvalidOperationException(); } GC.AddMemoryPressure(10485760); _processes = new List <Process>(); }
public Job(string name, long size) { _sizeInByte = size; _hJob = NativeJob.CreateJobObject(IntPtr.Zero, name); if (_hJob == IntPtr.Zero) { throw new InvalidOperationException(); } _processes = new List <Process>(); GC.AddMemoryPressure(_sizeInByte); Console.WriteLine("job was created."); }
/// <summary> /// 3. Implement the constructor of the Job class, /// that accepts a string called “name”: /// a. Call NativeJob.CreateJobObject passing IntPtr.Zero and the name argument. /// Store the returning handle in _hJob. /// b. If the handle is zero (IntPtr.Zero), throw an InvalidOperationException. /// c. Create the _processes object. /// </summary> /// <param name="name"></param> public Job(string name, int sizeInByte) { _hJob = NativeJob.CreateJobObject(IntPtr.Zero, name); if (_hJob == IntPtr.Zero) { throw new InvalidOperationException(); } _processes = new List <Process>(); _sizeInByte = sizeInByte; if (_sizeInByte > 0) { GC.AddMemoryPressure(sizeInByte); } Console.WriteLine($"A Job with the name {name} has created with ask for {sizeInByte} (sizeInByte) memory from the GC "); }
public Job(string name, long sizeInByte) { _name = name; _hJob = NativeJob.CreateJobObject(IntPtr.Zero, name); if (_hJob == IntPtr.Zero) { throw new InvalidOperationException(); } if (sizeInByte <= 0) { throw new ArgumentException("you can't send a size that is smaller then 1"); } GC.AddMemoryPressure(sizeInByte); _sizeInByte = sizeInByte; _processes = new List <Process>(); Console.WriteLine("Job created"); }
public Job(string name, long sizeInByte) { if (sizeInByte > 0) { SizeInByte = sizeInByte; _hJob = NativeJob.CreateJobObject(IntPtr.Zero, name); if (_hJob.Equals(IntPtr.Zero)) { throw new InvalidOperationException(); } _processes = new List <Process>(); Disposed = false; GC.AddMemoryPressure(SizeInByte); Console.WriteLine("The Job was created"); } else { throw new ArgumentOutOfRangeException(); } }
public Job(string name) { this._hJob = NativeJob.CreateJobObject(IntPtr.Zero, name); IsHandleNotZero(this._hJob); _processes = new List <Process>(); }