콘솔이 종료 방지

프로그램을 방지하기위한 한 가지 방법은 급증의 서버에서 콘솔을 종료합니다.

클래스 프로그램 
    { 
        프로그램을 중지하는 데 사용은 // 종료 
        개인  정적  읽기 전용 으로 ManualResetEvent _shutdownBlock = 새로운 새로운 으로 ManualResetEvent ( 거짓 )
         정적  무효 메인 ( 문자열 []에 args) 
        { 
            Console.WriteLine ( " 여보세요 세계! " ) 
       다른 스레드를 시작 //
// Console.Read (); Console.CancelKeyPress + = Console_CancelKeyPress; AppDomain.CurrentDomain.ProcessExit + = (송신자는 EventArgs) => {
          // 트리거 신호가 종료 기다려야 _shutdownBlock.WaitOne (); }; } // Ctrl + C退出程序
개인 정적 무효 Console_CancelKeyPress ( 오브젝트 송신자 ConsoleCancelEventArgs E) { e.Cancel = ; _shutdownBlock.Set (); } }

 또 다른 : asp.net의 핵심은이 방법을 사용

 

추천

출처www.cnblogs.com/imiyu/p/11102483.html