Welcome to mirror list, hosted at ThFree Co, Russian Federation.

TestExceptionHandler.cs « util « nunit20 « mcs - github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 5787ec8170ad7e42d4df6c7087f5a99b42f04c6a (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
41
42
43
44
45
46
using System;

namespace NUnit.Util
{
	/// <summary>
	/// Summary description for UnhandledExceptionCatcher.
	/// </summary>
	public class TestExceptionHandler : IDisposable
	{
		private UnhandledExceptionEventHandler handler;

		public TestExceptionHandler( UnhandledExceptionEventHandler handler )
		{
#if !TARGET_JVM
			this.handler = handler;
			AppDomain.CurrentDomain.UnhandledException += handler;
#endif
		}

		~TestExceptionHandler()
		{
#if  !TARGET_JVM
			if ( handler != null )
			{
				AppDomain.CurrentDomain.UnhandledException -= handler;
				handler = null;
			}
#endif
		}



		public void Dispose()
		{
#if !TARGET_JVM
			if ( handler != null )
			{
				AppDomain.CurrentDomain.UnhandledException -= handler;
				handler = null;
			}

			System.GC.SuppressFinalize( this );
#endif
		}
	}
}