2010-03-31 1 views

답변

97

AppDomainProcessExit 이벤트를보십시오 :

using System; 
class Test { 
    static void Main(string[] args) 
    { 
     AppDomain.CurrentDomain.ProcessExit += new EventHandler (OnProcessExit); 
     // Do something here 
    } 

    static void OnProcessExit (object sender, EventArgs e) 
    { 
     Console.WriteLine ("I'm out of here"); 
    } 
} 
+0

이 더 나은 작동합니다. – 7wp

+0

내 대답이 잘못되었습니다. 이것이 최선의 방법입니다. – ace

+0

이것은 가장 일반적인 솔루션이지만 'ProcessExit' 이벤트는 응용 프로그램이 종료 될 때 종료 자처럼 3 초로 제한됩니다. http://msdn.microsoft.com/en-us/library/system.appdomain.processexit.aspx –