コード例 #1
0
ファイル: Job.cs プロジェクト: moran321/dotNetCourse
        //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");
        }
コード例 #2
0
ファイル: Job.cs プロジェクト: yarivbracha/repository
 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!");
     }
 }
コード例 #3
0
 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>();
 }
コード例 #4
0
ファイル: Job.cs プロジェクト: AndreyLinetsky/CodeValueCourse
 public Job(string name)
 {
     _hJob = NativeJob.CreateJobObject(IntPtr.Zero, name);
     if (_hJob == IntPtr.Zero)
     {
         throw new InvalidOperationException();
     }
     _processes = new List <Process>();
     _disposed  = false;
 }
コード例 #5
0
ファイル: Job.cs プロジェクト: nellya27/labsOfCodeValue
 public Job(string name)
 {
     _hJob = NativeJob.CreateJobObject(IntPtr.Zero, name);
     if (_hJob == IntPtr.Zero)
     {
         throw new InvalidOperationException();
     }
     GC.AddMemoryPressure(10485760);
     _processes = new List <Process>();
 }
コード例 #6
0
        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.");
        }
コード例 #7
0
        /// <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 ");
        }
コード例 #8
0
        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");
        }
コード例 #9
0
ファイル: Job.cs プロジェクト: Lidoris/Lidor_IsmachMoshe
        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();
            }
        }
コード例 #10
0
 public Job(string name)
 {
     this._hJob = NativeJob.CreateJobObject(IntPtr.Zero, name);
     IsHandleNotZero(this._hJob);
     _processes = new List <Process>();
 }