Bladeren bron

Use ExceptionDispatchInfo to retain call stack in AsyncResult.EndInvoke() (#1470)

Scott Xu 1 jaar geleden
bovenliggende
commit
a067e2852a
1 gewijzigde bestanden met toevoegingen van 2 en 1 verwijderingen
  1. 2 1
      src/Renci.SshNet/Common/AsyncResult.cs

+ 2 - 1
src/Renci.SshNet/Common/AsyncResult.cs

@@ -1,4 +1,5 @@
 using System;
+using System.Runtime.ExceptionServices;
 using System.Threading;
 
 namespace Renci.SshNet.Common
@@ -85,7 +86,7 @@ namespace Renci.SshNet.Common
             // Operation is done: if an exception occurred, throw it
             if (_exception != null)
             {
-                throw _exception;
+                ExceptionDispatchInfo.Capture(_exception).Throw();
             }
         }