#if NET_4_5
+using System.Threading;
using System.Threading.Tasks;
+using System.Runtime.ExceptionServices;
namespace System.Runtime.CompilerServices
{
public TResult GetResult ()
{
+ if (!task.IsCompleted)
+ task.WaitCore (Timeout.Infinite, CancellationToken.None, true);
+
if (task.Status != TaskStatus.RanToCompletion)
- throw TaskAwaiter.HandleUnexpectedTaskResult (task);
+ ExceptionDispatchInfo.Capture (TaskAwaiter.HandleUnexpectedTaskResult (task)).Throw ();
return task.Result;
}