コード例 #1
0
 public void Queued_And_Then_Left_Over_A_Period_Of_Time_With_Queue_Per_Worker()
 {
     MessageConsumer consumer = new MessageConsumer();
       ThreadPool pool = new ThreadPool(ThreadPoolConfiguration.FiveAndTen, new QueuePerWorkerStrategy());
       pool.Start();
       foreach (Message message in MessageBuilder.MakeMessages(30))
       {
     pool.Queue(consumer, message);
       }
       Thread.Sleep(TimeSpan.FromSeconds(10.0));
       pool.Stop();
       Assert.AreEqual(30, consumer.NumberOfMessagesProcessed);
 }
コード例 #2
0
 public void Queued_Randomly_For_Twenty_Seconds()
 {
     ThreadPool pool = new ThreadPool(ThreadPoolConfiguration.FiveAndTen, new SingleQueueStrategy());
       pool.Start();
       DateTime startedAt = DateTime.Now;
       while (DateTime.Now - startedAt < TimeSpan.FromSeconds(10.0))
       {
     foreach (Message message in MessageBuilder.MakeMessages(Random.Next(10)))
     {
       pool.Queue(new MessageConsumer(), message);
     }
     Thread.Sleep(TimeSpan.FromSeconds(Random.NextDouble()));
       }
       pool.Stop();
 }