在我们的应用程序中实施触摸 ID

implementation of touch ID in our app

谁能解释 replyHandler 和 InvokeOnMainThread 在这段代码中的工作原理 enter code here。我已经从一个示例项目中复制了这段代码,我需要在我的项目中实现这个东西

partial void UIButton7_TouchUpInside (UIButton sender)
    {
        var context = new LAContext ();

        var error = new NSError ();
        if (context.CanEvaluatePolicy (LAPolicy.DeviceOwnerAuthenticationWithBiometrics,out error)) {
            var replyHandler = new LAContextReplyHandler((success, err) => {
                this.InvokeOnMainThread(() => {
                    if(success){
                        Console.WriteLine("You Logged in");
                    } else {
                        var errorAlertView = new UIAlertView("Login Error", err.LocalizedDescription, null, "Close");
                        errorAlertView.Show();
                    }
                });
            });
            context.EvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, "You need to login", replyHandler);
        }
    }

回复处理程序基本上是一个回调,用于在从触摸 ID 获取结果时管理反馈。

InvokeOnMainThread 允许在返回此结果时显示 ui 更改。它强制在 ui 线程上以能够反映 ui 更改。