From ac4f70b8ef9fc57983b312c21461aed0efcec297 Mon Sep 17 00:00:00 2001 From: chrmann Date: Mon, 5 Aug 2019 14:49:08 -0700 Subject: [PATCH] Attach exception to task so it can be properly re-thrown --- .../Platforms/net45/WebUI.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.IdentityModel.Clients.ActiveDirectory/Platforms/net45/WebUI.cs b/src/Microsoft.IdentityModel.Clients.ActiveDirectory/Platforms/net45/WebUI.cs index 6b60a5602..b87f20c62 100644 --- a/src/Microsoft.IdentityModel.Clients.ActiveDirectory/Platforms/net45/WebUI.cs +++ b/src/Microsoft.IdentityModel.Clients.ActiveDirectory/Platforms/net45/WebUI.cs @@ -63,8 +63,14 @@ public async Task AcquireAuthorizationAsync(Uri authorizati { var sendAuthorizeRequestWithTcs = new Action((t) => { - authorizationResult = Authenticate(authorizationUri, redirectUri); - ((TaskCompletionSource)t).TrySetResult(null); + try + { + authorizationResult = Authenticate(authorizationUri, redirectUri); + ((TaskCompletionSource)t).TrySetResult(null); + }catch(Exception e) + { + ((TaskCompletionSource)t).TrySetException(e); + } }); // The Post is needed here to ensure that the Authenticate() execution is posted to the message queue