gpt4 book ai didi

c# - 如何打破 IAsyncResult?

转载 作者:太空宇宙 更新时间:2023-11-03 15:23:46 25 4
gpt4 key购买 nike

<分区>

我想在 status == NBiometricStatus.Ok 时打破 Verification(IAsyncResult r) 但我的这段代码没有打破我的循环,所以请帮助我。 ..

    private void OnCapturingCompleted(IAsyncResult r)
{
var enrollTask = new NBiometricTask(NBiometricOperations.Enroll);

try
{
if (InvokeRequired)
{
BeginInvoke(new AsyncCallback(OnCapturingCompleted), r);
}
else
{
NBiometricStatus status = _mbiometricClient.EndCapture(r);
// If Stop button was pushed
if (status == NBiometricStatus.Canceled) return;

M_lblStatus.Text = status.ToString();
if (status != NBiometricStatus.Ok)
{
_mbiometricClient.ForceStart();

}
else
{
DataTable dt = QueryMaster.GetFaceData();


for (int i = 0; i < dt.Rows.Count; i++)
{
byte[] b1 = System.Convert.FromBase64String(dt.Rows[i]["F_feature"].ToString());
_Rsubject = new NSubject();
_Rsubject.SetTemplateBuffer(NBuffer.FromArray(b1));

if (_subject != null && _Rsubject != null)
{
_mbiometricClient.BeginVerify(_subject, _Rsubject, Verification, null);
if (result != null)
{
break;
}
}

}
}
}
}
catch (Exception ex) { }
finally
{
}

}

private void Verification(IAsyncResult r)
{
string msg;
try
{
if (InvokeRequired)
{
BeginInvoke(new AsyncCallback(Verification), r);
}
else
{
try
#region foreloop
{

foreach (NMatchingResult t in _subject.MatchingResults)
{
NBiometricStatus status = _mbiometricClient.EndVerify(r);
var verificationStatus = string.Format("Verification status: {0}", status);
if (status == NBiometricStatus.Ok)
{
//get matching score
int score = _subject.MatchingResults[0].Score;
msg = string.Format("Score of matched templates: {0}", score);
msg += " " + verificationStatus;
lblFinalStatus.Text = msg;
//MessageBox.Show(msg);
result = msg;
//EndInvoke(r);
Func<string> function = r.AsyncState as Func<string>;
msg = function.EndInvoke(r);

break;
}
else
{
lblFinalStatus.Text = verificationStatus;
count += 1;
if (count == 10)
{
MessageBox.Show(string.Format("{0}\n{1}", verificationStatus, "Face doesn't Exist..!"));
}
_mbiometricClient.ForceStart();
}
}

}
catch (Exception ex)
{
Utils.ShowException(ex);
}
#endregion

}
if (result != null)
{

Func<string> function = r.AsyncState as Func<string>;
msg = function.EndInvoke(r);
}
}
catch (Exception ex) { }


}

这是我的EndVerify()

public NBiometricStatus EndVerify(IAsyncResult asyncResult);

这是我的BeginVerify()

public IAsyncResult BeginVerify(NSubject subject, AsyncCallback callback, object state);

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com