Merge pull request #900 from Blewzman/FixAggregateExceptionGetBaseException
[mono.git] / mcs / class / corlib / System.Runtime.CompilerServices / ConfiguredTaskAwaitable_T.cs
index 380c05f3febb5602c81fe99bdef77a21c75d70e8..b96b1cc6f377fcf8804ef705575310231959facb 100644 (file)
@@ -28,6 +28,7 @@
 
 #if NET_4_5
 
+using System.Threading;
 using System.Threading.Tasks;
 using System.Runtime.ExceptionServices;
 
@@ -54,6 +55,9 @@ namespace System.Runtime.CompilerServices
 
                        public TResult GetResult ()
                        {
+                               if (!task.IsCompleted)
+                                       task.WaitCore (Timeout.Infinite, CancellationToken.None, true);
+
                                if (task.Status != TaskStatus.RanToCompletion)
                                        ExceptionDispatchInfo.Capture (TaskAwaiter.HandleUnexpectedTaskResult (task)).Throw ();