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