Created
October 11, 2017 16:53
-
-
Save alx9r/510d3bffa7a54394259af6783d332393 to your computer and use it in GitHub Desktop.
Task<TResult>.Result throws exception
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Threading.Tasks; | |
namespace ConsoleApplication1 | |
{ | |
public class Thrower | |
{ | |
public string Throw() | |
{ | |
throw new System.Exception("some exception"); | |
return "return value"; | |
} | |
public System.Func<string> GetThrow | |
{ | |
get { return Throw; } | |
} | |
} | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
Task<string> t = new Task<string>((new Thrower()).GetThrow); | |
t.Start(); | |
Console.WriteLine(t.Result); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment