linux-packaging-mono/mcs/tests/test-async-93.cs
Xamarin Public Jenkins (auto-signing) 966bba02bb Imported Upstream version 5.2.0.175
Former-commit-id: bb0468d0f257ff100aa895eb5fe583fb5dfbf900
2017-06-07 13:16:24 +00:00

44 lines
604 B
C#

using System;
using System.Threading.Tasks;
public class Test
{
public static int Main()
{
var t = new Test ();
t.Entry().Wait();
if (t.caughtCounter != 1)
return 1;
return 0;
}
int caughtCounter;
async Task Entry()
{
for (int i = 0; i < 5; ++i) {
try {
var result = Func(i);
Console.WriteLine($"{i} result {result}");
} catch (Exception e) {
await Nothing();
Console.WriteLine($"{i} caught");
++caughtCounter;
}
}
}
bool Func(int i)
{
if (i == 0) {
throw new Exception();
} else {
return true;
}
}
async Task Nothing()
{
}
}