以下代码可以很好地执行,但是即使放置断点表明t.Completed调用也不会更新标签文本。返回lblMsg.InnerHtml =“请访问您的电子邮件以重设密码”。 我显然对异步还不太满意;-)。谢谢。
Private Async Function ResetPassword() As Task
Dim API_KEY As String = "AIzaSyD9iS5-Zp6fP5phEOq8HVUf5cU9*****"
Try
Dim email As String = txtEmail.Text
Dim firebaseAuth = New FirebaseAuthProvider(New FirebaseConfig(API_KEY))
Await firebaseAuth.SendPasswordResetEmailAsync(email).ContinueWith(
Function(t)
If t.IsFaulted Then
Return errMsg.InnerHtml = t.Exception.InnerException.Message
End If
If t.IsCanceled Then Return errMsg.InnerHtml = "Canceled"
If t.IsCompleted Then Return lblMsg.InnerHtml = "Please access your email in order to reset your password"
Return lblMsg.InnerHtml = "Unexpected error."
End Function)
Catch ex As FirebaseAuthException
errMsg.InnerHtml = ex.GetBaseException.Message
End Try
Return
End Function
呼叫代码
Private Sub btnResetPWD_Click(sender As Object, e As EventArgs) Handles btnResetPWD.Click
Dim LoadTask As New PageAsyncTask(AddressOf ResetPassword)
Page.RegisterAsyncTask(LoadTask)
End Sub