public void Execute(int index)
            {
                T_Job job = jobsResult[index];

                job.ExecuteEvent(evs[index].ev);
                jobsResult[index] = job;
            }
 public Subscription(EventTarget target, T_Job job)
 {
     this.target = target;
     this.job    = job;
 }
示例#3
0
        public void RunJob(T_Job job)
        {
            TimeSpan runTime = TimeSpan.FromSeconds(testRunDataProvider.GetExectutionTime());

            Console.WriteLine(Environment.NewLine);
            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("----- Starting Job: {0} -----", job.name);
            Console.WriteLine(DateTime.Now.ToLocalTime().ToString());
            Console.WriteLine(Environment.NewLine);
            Console.ForegroundColor = ConsoleColor.Gray;
            List <Thread> threads = new List <Thread>();

            if (job.Threads != null)
            {
                if (job.Threads.Thread != null)
                {
                    foreach (T_Thread thread in job.Threads.Thread)
                    {
                        int concurrentThreadCount = 1;
                        if (thread.ThreadCopiesSpecified && thread.ThreadCopies > 1)
                        {
                            concurrentThreadCount = thread.ThreadCopies;
                        }
                        threads.AddRange(StartThread(thread, job.name, runTime, concurrentThreadCount));
                    }
                }
                if (job.Threads.ThreadRef != null)
                {
                    foreach (T_ThreadRef threadref in job.Threads.ThreadRef)
                    {
                        T_Thread thread = testRunDataProvider.GetThreadFromRefId(threadref.Id);
                        int      concurrentThreadCount = 1;
                        if (threadref.ThreadCopiesSpecified && threadref.ThreadCopies > 1)
                        {
                            concurrentThreadCount = threadref.ThreadCopies;
                        }
                        threads.AddRange(StartThread(thread, job.name, runTime, concurrentThreadCount));
                    }
                }
            }
            bool threadsFinished = false;

            while (!threadsFinished)
            {
                threadsFinished = true;
                foreach (Thread thread in threads)
                {
                    if (thread.ThreadState == ThreadState.Running)
                    {
                        threadsFinished = false;
                        Thread.Sleep(1000);
                        break;
                    }
                }
            }
            Console.WriteLine(Environment.NewLine);
            Console.ForegroundColor = ConsoleColor.Red;
            Console.WriteLine(System.DateTime.Now.ToLocalTime().ToString());
            Console.WriteLine("----- Finished Job: {0} -----", job.name);
            Console.ForegroundColor = ConsoleColor.Gray;
            Console.WriteLine(Environment.NewLine);
        }