Use async-wait pattern in HandleAuthenticateOnceSafeAsync

This commit is contained in:
Troy Dai 2016-08-05 14:34:36 -07:00
parent 0314632696
commit 926c7fab4b
1 changed files with 3 additions and 6 deletions

View File

@ -255,18 +255,15 @@ namespace Microsoft.AspNetCore.Authentication
/// This method won't throw exception. Any exception thrown during the authentication will be convert
/// to a AuthenticateResult.
/// </summary>
protected Task<AuthenticateResult> HandleAuthenticateOnceSafeAsync()
protected async Task<AuthenticateResult> HandleAuthenticateOnceSafeAsync()
{
try
{
return HandleAuthenticateOnceAsync().ContinueWith<AuthenticateResult>(
task => task.IsFaulted ? AuthenticateResult.Fail(task.Exception) : task.Result
);
return await HandleAuthenticateOnceAsync();
}
catch (Exception ex)
{
// capture exception which is thrown before the task is actually started
return Task.FromResult(AuthenticateResult.Fail(ex));
return AuthenticateResult.Fail(ex);
}
}