summaryrefslogtreecommitdiff
path: root/tests/src/baseservices/exceptions/regressions/V1/SEH/VJ/RecursiveException.cs
blob: 052a48868ad0f4b66aac7f67d9ae5df6f41d1248 (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
47
48
49
50
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Threading;
using System.IO;

class UserException : Exception {
	
}

public class RecursiveException {
	public static int Main(String [] args) {
		String s = "Done";
		int retVal = 100;
		Thread mv_Thread;
		RecursiveException re = new RecursiveException();
		for (int i = 0 ; i < 10; i++){
			mv_Thread = new Thread(new ThreadStart(re.runtest));
			try {
				mv_Thread.Start();
			}
			catch (Exception ){
				    Console.WriteLine("Exception was caught in main");
					retVal = 0;
			}
		}
		Console.WriteLine(s);
		return retVal;
	}
		
	public void runtest(){
		try {
			recurse(0);
		}
		catch (UserException ) {
		    lock(this)
			{
			    Console.WriteLine("The Exception was caught");
			}
		}
	}
	
	public void recurse(int counter) {	
		if (counter == 1000) 
			throw new UserException();
		else
			recurse(++counter);
	}
}