You've already forked linux-packaging-mono
Imported Upstream version 4.4.0.40
Former-commit-id: 6427cc082e74df30afc535fd906a3494b74b0817
This commit is contained in:
34
mcs/tests/test-async-83.cs
Normal file
34
mcs/tests/test-async-83.cs
Normal file
@ -0,0 +1,34 @@
|
||||
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";
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user