Beispiel #1
0
        public void EnqueueWaitFailTooTest()
        {
            var scheduledRunner = new BatchRunner <Param, bool>(TimeSpan.FromMilliseconds(100), 10, 1024, TimeSpan.FromMilliseconds(1000), TimeSpan.FromMilliseconds(1000), new BatchWorker());

            scheduledRunner.Start();

            var event1    = new ManualResetEvent(false);
            var workItem1 = new WorkItem <Param, bool>(event1, new Param());

            scheduledRunner.EnqueueItem(workItem1);

            var event2    = new ManualResetEvent(false);
            var workItem2 = new WorkItem <Param, bool>(event2, new Param());

            scheduledRunner.EnqueueItem(workItem2);

            event1.WaitOne(scheduledRunner.WaitTime);
            event2.WaitOne(scheduledRunner.WaitTime);

            scheduledRunner.Stop();

            Assert.IsTrue(workItem1.Result);
            Assert.IsFalse(workItem2.Result);
        }
Beispiel #2
0
        public void StoppingEnqueueWaitTest()
        {
            var scheduledRunner = new BatchRunner <Param, bool>(TimeSpan.FromMilliseconds(100), 10, 1024, TimeSpan.FromMilliseconds(1000), TimeSpan.FromMilliseconds(1000), new BatchWorker());

            scheduledRunner.Start();

            var @event   = new ManualResetEvent(false);
            var workItem = new WorkItem <Param, bool>(@event, new Param());

            scheduledRunner.Stop();

            scheduledRunner.EnqueueItem(workItem);

            @event.WaitOne(scheduledRunner.WaitTime);

            Assert.IsFalse(workItem.Result);
        }