Merge pull request #5714 from alexischr/update_bockbuild
[mono.git] / mono / tests / main-returns-background-abort-resetabort.cs
1
2 using System;
3 using System.Threading;
4
5 public class foo {
6         public static void Main() {
7                 Thread thr=new Thread(new ThreadStart(foo.thread));
8                 thr.IsBackground=true;
9                 thr.Start();
10                 Thread.Sleep(600);
11                 Console.WriteLine("Aborting child thread");
12                 thr.Abort();
13                 Thread.Sleep(600);
14                 Console.WriteLine("Main thread returns");
15         }
16
17         public static void thread() {
18                 try {
19                         Console.WriteLine("Thread running");
20                         Thread.Sleep(500);
21                 } catch(ThreadAbortException) {
22                         Thread.ResetAbort();
23                         Console.WriteLine("Abort reset!");
24                 } finally {
25                         Console.WriteLine("ThreadAbortException finally");
26                 }
27                 try {
28                         Console.WriteLine("Thread running");
29                         Thread.Sleep(500);
30                 } catch(ThreadAbortException) {
31                         Thread.ResetAbort();
32                         Console.WriteLine("Abort reset!");
33                 } finally {
34                         Console.WriteLine("ThreadAbortException finally");
35                 }
36                 try {
37                         Console.WriteLine("Thread running");
38                         Thread.Sleep(500);
39                 } catch(ThreadAbortException) {
40                         Thread.ResetAbort();
41                         Console.WriteLine("Abort reset!");
42                 } finally {
43                         Console.WriteLine("ThreadAbortException finally");
44                 }
45                 try {
46                         Console.WriteLine("Thread running");
47                         Thread.Sleep(500);
48                 } catch(ThreadAbortException) {
49                         Thread.ResetAbort();
50                         Console.WriteLine("Abort reset!");
51                 } finally {
52                         Console.WriteLine("ThreadAbortException finally");
53                 }
54                 try {
55                         Console.WriteLine("Thread running");
56                 } catch(ThreadAbortException) {
57                         Thread.ResetAbort();
58                         Console.WriteLine("Abort reset!");
59                 } finally {
60                         Console.WriteLine("ThreadAbortException finally");
61                 }
62         }
63 }
64