예제 #1
0
 static void Main(string[] args)
 {
     Job myJob = new Job("manage_resources");
     myJob.AddProcessToJob(Process.Start("notepad"));
     myJob.AddProcessToJob(Process.Start("calc"));
     Console.WriteLine("Press enter to kill the job");
     Console.ReadLine();
     myJob.Kill();
     uint count = 0;
     for (uint i = 0; i <= 20; i++)
     {
         var newJob = new Job(count);
         count += 500000;
     }
     Console.ReadLine();
 }
예제 #2
0
        /// <summary>
        /// Creates a new job object.
        /// </summary>
        private Guid CreateJob(
            Guid pParentID,
            string pName,
            string pCode,
            iTaskCollection pTaskCollection,
            iJobContextFactory pJobContextFactory,
            iJobState pJobState,
            int pMaxErrors)
        {
            if (string.IsNullOrWhiteSpace(pName))
            {
                throw new NullReferenceException("Invalid name for a job.");
            }
            if (string.IsNullOrWhiteSpace(pCode))
            {
                throw new NullReferenceException("Invalid code for a job.");
            }
            if (pTaskCollection == null)
            {
                throw new NullReferenceException("pTaskFactory can not be null.");
            }
            if (pJobContextFactory == null)
            {
                throw new NullReferenceException("pContextFactory can not be null.");
            }
            if (pJobState == null)
            {
                throw new NullReferenceException("pJobState can not be null.");
            }

            Job job = new Job(
                pParentID,
                _settings,
                Name,
                pName,
                pCode,
                pTaskCollection,
                pJobContextFactory,
                ObjectFactory.Container.GetInstance<iEventFactory>(),
                pJobState,
                pMaxErrors);

            Jobs.Add(job.ID, job);
            return job.ID;
        }
예제 #3
0
        public void Run()
        {
            Job firstJob = new Job();
            Process calcProcess = Process.Start("calc");
            Debug.Assert(calcProcess != null);
            firstJob.AddProcessToJob(calcProcess);
            Process notepadProcess = Process.Start("notepad");
            Debug.Assert(notepadProcess != null);
            firstJob.AddProcessToJob(notepadProcess);
            Console.WriteLine("Press enter to kill all firstJob processes");
            Console.ReadLine();
            firstJob.Kill();

            Job[] JobArray = new Job[20];
            string name;
            int memorySize = 1;
            for (int i = 1; i < 21; i++)
            {
                name = "Job " + i;
                JobArray[i - 1] = new Job(name, memorySize);
                memorySize += 500000;
            }
        }