2005-01-31 Zoltan Varga <vargaz@freemail.hu>
[mono.git] / mcs / nunit20 / util / TestExceptionHandler.cs
1 using System;
2
3 namespace NUnit.Util
4 {
5         /// <summary>
6         /// Summary description for UnhandledExceptionCatcher.
7         /// </summary>
8         public class TestExceptionHandler : IDisposable
9         {
10                 private UnhandledExceptionEventHandler handler;
11
12                 public TestExceptionHandler( UnhandledExceptionEventHandler handler )
13                 {
14                         this.handler = handler;
15                         AppDomain.CurrentDomain.UnhandledException += handler;
16                 }
17
18                 ~TestExceptionHandler()
19                 {
20                         if ( handler != null )
21                         {
22                                 AppDomain.CurrentDomain.UnhandledException -= handler;
23                                 handler = null;
24                         }
25                 }
26
27
28
29                 public void Dispose()
30                 {
31                         if ( handler != null )
32                         {
33                                 AppDomain.CurrentDomain.UnhandledException -= handler;
34                                 handler = null;
35                         }
36
37                         System.GC.SuppressFinalize( this );
38                 }
39         }
40 }