Exemplo n.º 1
0
        public void ThreadPoolShouldRunTasksWithoutAnyArguments()
        {
            System.Threading.ManualResetEvent canContinue = new System.Threading.ManualResetEvent(false);

            ThreadPoolImpl pool = new ThreadPoolImpl();

            bool argumentIsNull = false;

            pool.StartTask((obj) => {
                argumentIsNull = null == obj;
                canContinue.Set();
            });

            Assert.True(canContinue.WaitOne(1000));
            Assert.True(argumentIsNull);
        }
Exemplo n.º 2
0
        public void ThreadPoolShouldRunTasksWithArgument()
        {
            System.Threading.ManualResetEvent canContinue = new System.Threading.ManualResetEvent(false);

            ThreadPoolImpl pool = new ThreadPoolImpl();

            object o           = new object();
            bool   gotArgument = false;

            pool.StartTask((obj) => {
                gotArgument = object.ReferenceEquals(obj, o);
                canContinue.Set();
            }, o);

            Assert.True(canContinue.WaitOne(1000));
            Assert.True(gotArgument);
        }