상속: AbstractWorkerThread
예제 #1
0
        public void CountUpThreadTest()
        {
            if (log.IsInfoEnabled)
            {
                log.Info("main : BEGIN");
            }

            try {
                var thread = new CountUpThread("Counter Thread");

                thread.ThreadStarted         += ThreadThreadStarted;
                thread.ThreadFinished        += ThreadThreadFinished;
                thread.ShutDownRequested     += ThreadShutDownRequested;
                thread.ThreadProgressChanged += ThreadThreadProgressChanged;

                thread.Start();

                ThreadTool.Sleep(5000);

                if (log.IsInfoEnabled)
                {
                    log.Info("main : Call ShutDown() ");
                }

                thread.ShutDown();

                if (log.IsInfoEnabled)
                {
                    log.Info("main : Call Join() ");
                }

                thread.Join();

                Assert.IsFalse(thread.IsAlive);
            }
            catch (ThreadInterruptedException) {
                if (IsDebugEnabled)
                {
                    log.Debug("스레드가 Interrupt되었습니다.");
                }
            }

            if (log.IsInfoEnabled)
            {
                log.Info("main : END");
            }
        }
        public void CountUpThreadTest() {
            if(log.IsInfoEnabled)
                log.Info("main : BEGIN");

            try {
                var thread = new CountUpThread("Counter Thread");

                thread.ThreadStarted += ThreadThreadStarted;
                thread.ThreadFinished += ThreadThreadFinished;
                thread.ShutDownRequested += ThreadShutDownRequested;
                thread.ThreadProgressChanged += ThreadThreadProgressChanged;

                thread.Start();

                ThreadTool.Sleep(5000);

                if(log.IsInfoEnabled)
                    log.Info("main : Call ShutDown() ");

                thread.ShutDown();

                if(log.IsInfoEnabled)
                    log.Info("main : Call Join() ");

                thread.Join();

                Assert.IsFalse(thread.IsAlive);
            }
            catch(ThreadInterruptedException) {
                if(IsDebugEnabled)
                    log.Debug("스레드가 Interrupt되었습니다.");
            }

            if(log.IsInfoEnabled)
                log.Info("main : END");
        }