Ejemplo n.º 1
0
        public void TestFast()
        {
            const int n = 1000000;
            ActorClass[] actors = new ActorClass[Math.Max(Environment.ProcessorCount - 1, 1)];

            for (int i = 0; i < actors.Length; i++)
            {
                actors[i] = new ActorClass();
            }

            for (int i = 0; i < n; i++)
            {
                for (int j = 0; j < actors.Length; j++)
                {
                    actors[j].Fast();
                }
            }

            ManualResetEvent[] readyHandles = new ManualResetEvent[actors.Length];
            for (int i = 0; i < actors.Length; i++)
            {
                actors[i].Set(readyHandles[i] = new ManualResetEvent(false));
            }

            if (!WaitHandle.WaitAll(readyHandles, 20000))
                throw new TimeoutException();
        }
Ejemplo n.º 2
0
        public void Test()
        {
            ActorClass actorClass = new ActorClass();
            Task[] tasks = new Task[10];

            for (int i = 0; i < tasks.Length; i++)
            {
                tasks[i] = new Task(actorClass.Foo);
                tasks[i].Start();
            }

            Assert.True(actorClass.CountdownEvent.Wait(10000));

            Assert.AreEqual(10, actorClass.Count);
        }
Ejemplo n.º 3
0
        public void Test()
        {
            ActorClass actorClass = new ActorClass();

            Task[] tasks = new Task[10];

            for (int i = 0; i < tasks.Length; i++)
            {
                tasks[i] = new Task(actorClass.Foo);
                tasks[i].Start();
            }

            Assert.True(actorClass.CountdownEvent.Wait(10000));

            Assert.AreEqual(10, actorClass.Count);
        }