Exemplo n.º 1
0
        /// <summary>
        /// 생성자
        /// </summary>
        /// <param name="userDelegate">Thread 안에서 수행할 메소드</param>
        public CrossThreadRunner(ThreadStart userDelegate)
        {
            userDelegate.ShouldNotBeNull("userDelegate");

            _userDelegate  = userDelegate;
            _lastException = null;
        }
Exemplo n.º 2
0
        /// <summary>
        /// 지정된 Thread 메소드에 대해, 갯수 만큼 Thread 를 만들어서 실행시킨다. (ThreadPool 을 사용하는게 아니므로,
        /// 좋은 방법은 아닙니다. <see cref="TestTool.RunTasks(int,System.Action)"/>을 사용하세요.
        /// </summary>
        /// <param name="testMethod">실행할 메소드를 ThreadStart로 delegate 한 메소드</param>
        /// <param name="threadCount">수행할 횟수</param>
        /// <example>
        /// <code>
        ///		TestTool.ThreadStress(new ThreadStart(WorkMethod), 100);
        ///
        ///
        ///		...
        ///
        ///		public void WorkMethod()
        ///     {
        ///           // something to work
        ///           ...
        ///		}
        /// </code>
        /// </example>
        public static void ThreadStress(this ThreadStart testMethod, int threadCount = 4)
        {
            testMethod.ShouldNotBeNull("testMethod");
            threadCount.ShouldBePositive("threadCount");
            //if (threadCount <= 0)
            //    throw new ArgumentOutOfRangeException("threadCount", "threadCount should be greater than 0.");

            if (IsDebugEnabled)
            {
                log.Debug("스트레스 테스트를 위해 멀트 스레드를 실행합니다... testMethod=[{0}], threadCount=[{1}]", testMethod.Method.Name, threadCount);
            }

            IList <Thread> threads = new List <Thread>();

            for (var i = 0; i < threadCount; i++)
            {
                threads.Add(new Thread(testMethod));
            }

            threads.ThreadStress();
        }
Exemplo n.º 3
0
        /// <summary>
        /// 생성자
        /// </summary>
        /// <param name="userDelegate">Thread 안에서 수행할 메소드</param>
        public CrossThreadRunner(ThreadStart userDelegate) {
            userDelegate.ShouldNotBeNull("userDelegate");

            _userDelegate = userDelegate;
            _lastException = null;
        }