a575963da9
Former-commit-id: da6be194a6b1221998fc28233f2503bd61dd9d14
47 lines
1.1 KiB
C#
47 lines
1.1 KiB
C#
// ****************************************************************
|
|
// Copyright 2007, Charlie Poole
|
|
// This is free software licensed under the NUnit license. You may
|
|
// obtain a copy of the license at http://nunit.org/?p=license&r=2.4
|
|
// ****************************************************************
|
|
|
|
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 );
|
|
}
|
|
}
|
|
}
|