update readme (#21797)
[mono-project.git] / mono / tests / async-generic-enum.cs
blobb5410ddfef9bbe6b5eaabac552b3c96a2d3fc40a
1 using System;
2 using System.Threading.Tasks;
5 public enum someEnum2 {
6 aaa,
7 bbb
9 class Tests {
10 private static GenericEnumTest<someEnum2> test1 = new GenericEnumTest<someEnum2>();
11 public static async Task<int> Main(string[] args)
13 int retVal = await test1.ThrowExceptionWithGeneric(someEnum2.aaa);
14 return retVal;
18 public class GenericEnumTest<T> where T : struct {
19 public enum anEnum {
20 val1,
21 val2
24 public async Task<int> ThrowExceptionWithGeneric(T val) {
25 try {
26 await ThrowExceptionTaskReturn(val);
27 } catch (Exception e) {
28 Console.WriteLine(e);
30 return 0;
33 public async Task<anEnum> ThrowExceptionTaskReturn(T val) {
34 for (int i = 0; i < 3; i++) {
35 Console.WriteLine("[ASY] " + (3 - i) + " " + System.Threading.Thread.CurrentThread.ManagedThreadId);
36 await Task.Delay(TimeSpan.FromSeconds(1));
39 var nulla = default(string[]);
40 // Causes exception to fire, walking the stack trace causes nullpointer exception bug
41 var vala = nulla[0];
43 return anEnum.val1;