첨부 실행 코드는 나눔고딕코딩 폰트를 사용합니다.
728x90
반응형
728x170

▶ Program.cs

using System;
using System.Threading;

namespace TestProject
{
    /// <summary>
    /// 프로그램
    /// </summary>
    class Program
    {
        //////////////////////////////////////////////////////////////////////////////////////////////////// Method
        ////////////////////////////////////////////////////////////////////////////////////////// Static
        //////////////////////////////////////////////////////////////////////////////// Private

        #region 작업 처리하기 - ProcessJob(state)

        /// <summary>
        /// 작업 처리하기
        /// </summary>
        /// <param name="state">상태</param>
        private static void ProcessJob(object state)
        {
            ManualResetEvent manualResetEvent = state as ManualResetEvent;

            try
            {
                Console.WriteLine("작업 처리를 시작합니다.");

                Thread.Sleep(5000);

                Console.WriteLine("작업 처리를 종료합니다.");
            }
            finally
            {
                manualResetEvent.Set();
            }
        }

        #endregion
        #region 프로그램 시작하기 - Main()

        /// <summary>
        /// 프로그램 시작하기
        /// </summary>
        private static void Main()
        {
            ManualResetEvent manualResetEvent = new ManualResetEvent(false);

            if(ThreadPool.QueueUserWorkItem(ProcessJob, manualResetEvent))
            {
                manualResetEvent.WaitOne();

                Console.WriteLine("프로그램 실행을 종료합니다.");
            }
        }

        #endregion
    }
}
728x90
반응형
그리드형(광고전용)
Posted by icodebroker

댓글을 달아 주세요