Closed. This question is off-topic。它当前不接受答案。
想改善这个问题吗? Update the question,所以它是on-topic,用于堆栈溢出。
3年前关闭。
我想在
这是我的
这是我的
想改善这个问题吗? Update the question,所以它是on-topic,用于堆栈溢出。
3年前关闭。
我想在
Verification(IAsyncResult r)
时打破status == NBiometricStatus.Ok
,但是我的这段代码没有打破我的循环,所以请帮我... 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);
最佳答案
请检查_mbiometricClient.EndVerify(r);
是否具有执行的返回结果。在if语句中,在检查EndVerify
期间status
似乎仍在运行。您可能没有收到任务的结果。我的回答是基于EndVerify
是异步的假设。
10-04 14:35