linux-packaging-mono/mcs/tests/test-async-83.cs
Xamarin Public Jenkins a632333cc7 Imported Upstream version 4.4.0.40
Former-commit-id: 6427cc082e74df30afc535fd906a3494b74b0817
2016-03-16 12:38:19 -04:00

34 lines
573 B
C#

using System;
using System.Threading.Tasks;
class MainClass
{
public static int Main ()
{
var t = GetSomeStrings (null);
try {
var s = t.Result;
return 1;
} catch (AggregateException e) {
if (e.InnerException is NullReferenceException)
return 0;
return 2;
}
}
public static async Task<string> GetSomeStrings (AsyncStringFactory myFactory)
{
var res = await myFactory?.GetSomeStringAsync ();
return res;
}
}
public class AsyncStringFactory
{
public async Task<string> GetSomeStringAsync ()
{
await Task.Yield();
return "foo";
}
}