예제 #1
0
        static void Main(string[] args)
        {
            BenchmarkSystem bs = new BenchmarkSystem();
            Logger logger1 = new Logger();
            Logger logger2 = new Logger();
            Func<string[], int> function = (String) => 42;

            List<Job> list = new List<Job>();
            list.Add(new Job(new Owner("Boogie"), 4, 1, function));
            list.Add(new Job(new Owner("Mikkel"), 4, 50, function));
            list.Add(new Job(new Owner("The Blitz"), 4, 90, function));
            list.Add(new Job(new Owner("Mark"), 4, 110, function));
            list.Add(new Job(new Owner("Morten"), 4, 125, function));
            list.Add(new Job(new Owner("Andreas"), 4, 3893, function));

            foreach (Job job in list)
            {
                bs.Submit(job);
            }

            logger1.Subscribe(bs);

            bs.ExecuteAll();

            foreach (Job job in list)
            {
                bs.Submit(job);
            }

            logger2.Subscribe(bs);

            bs.ExecuteAll();
        }
예제 #2
0
파일: Logger.cs 프로젝트: Prechtig/BDSA2012
 /// <summary>
 /// Stop Listening to the given BenchmarkSystem
 /// </summary>
 /// <param name="bs">The BenchmarkSystem to stop listening to</param>
 public void Unsubscribe(BenchmarkSystem bs)
 {
     bs.JobSubmitted -= OnJobSubmitted;
     bs.JobCancelled -= OnJobCancelled;
     bs.JobRunning -= OnJobRunning;
     bs.JobTerminated -= OnJobTerminated;
     bs.JobFailed -= OnJobFailed;
 }
예제 #3
0
 public void CancelTest()
 {
     BenchmarkSystem bs = new BenchmarkSystem();
     bool isCancelled = false;
     Func<string[], int> function = (String) => { isCancelled = true; return 42; };
     Job job = new Job(new Owner("Boogie"), 4, 1, function);
     bs.Submit(job);
     bs.Cancel(job);
     bs.ExecuteAll();
     Assert.IsFalse(isCancelled);
 }