gpt4 book ai didi

c# - ZKemKeeper 库中的实时事件处理程序在一段时间后停止响应设备事件

转载 作者:太空狗 更新时间:2023-10-30 00:50:20 26 4
gpt4 key购买 nike

我已经创建了一个简单的 Windows 服务项目来使用 ZKemKeeper 库从指纹设备捕获实时事件。该服务在第一时间似乎正常工作,并且它对设备中的事件响应良好。但我发现,服务在几分钟不活动后停止响应事件。我以为是服务导致了问题,但问题仍然存在于 WinForm 应用程序中,甚至 SDK 中包含的示例也显示了确切的问题。

这是 Windows 服务的代码:

public partial class Service1 : ServiceBase
{
private System.Diagnostics.EventLog eventLog1;
CZKEMClass myCZKEMClass;
public Service1()
{
InitializeComponent();

this.eventLog1 = new System.Diagnostics.EventLog();


((System.ComponentModel.ISupportInitialize)(this.eventLog1)).BeginInit();
this.eventLog1.Log = "MyLog";
this.eventLog1.Source = "MyLogSource";

((System.ComponentModel.ISupportInitialize)(this.eventLog1)).EndInit();

this.ServiceName = "ZKemKeeperTestService";


}

protected override void OnStart(string[] args)
{
myCZKEMClass = new CZKEMClass();

Thread createComAndMessagePumpThread = new Thread(() =>
{
myCZKEMClass.Connect_Net("192.168.1.20", 4370);


if (myCZKEMClass.RegEvent(1, 65535))
{
myCZKEMClass.OnAttTransactionEx += new _IZKEMEvents_OnAttTransactionExEventHandler(myCZKEMClass_OnAttTransactionEx);
}

Application.Run();
});
createComAndMessagePumpThread.SetApartmentState(ApartmentState.STA);

createComAndMessagePumpThread.Start();

eventLog1.WriteEntry("Service Started");

}


protected override void OnStop()
{
eventLog1.WriteEntry("Service Stopped");
myCZKEMClass.OnAttTransactionEx -= new _IZKEMEvents_OnAttTransactionExEventHandler(myCZKEMClass_OnAttTransactionEx);

}

private void myCZKEMClass_OnAttTransactionEx(string EnrollNumber, int IsInValid, int AttState, int VerificationMethod, int Year, int Month, int Day, int Hour, int Minute, int Second, int WorkCode)
{

eventLog1.WriteEntry(EnrollNumber.ToString());

}
}

我不知道问题的原因是什么,我被困在那里。仅供引用,我使用的是在 Windows 10 中运行的 64 位版本库。我使用 .NET Framework 4.0 作为目标框架。

艾哈迈德穆利亚迪

最佳答案

我和你有同样的问题,请尝试取消注册该事件,然后每 60 秒重新注册一次,这对我有用。我使用的是在 Windows 8.1 中运行的 64 位版本 og 库

        if (bIsConnected == true)
{
this.axCZKEM1.OnFinger -= new zkemkeeper._IZKEMEvents_OnFingerEventHandler(axCZKEM1_OnFinger);
this.axCZKEM1.OnVerify -= new zkemkeeper._IZKEMEvents_OnVerifyEventHandler(axCZKEM1_OnVerify);
this.axCZKEM1.OnAttTransactionEx -= new zkemkeeper._IZKEMEvents_OnAttTransactionExEventHandler(axCZKEM1_OnAttTransactionEx);
this.axCZKEM1.OnFingerFeature -= new zkemkeeper._IZKEMEvents_OnFingerFeatureEventHandler(axCZKEM1_OnFingerFeature);
this.axCZKEM1.OnEnrollFingerEx -= new zkemkeeper._IZKEMEvents_OnEnrollFingerExEventHandler(axCZKEM1_OnEnrollFingerEx);

iMachineNumber = 1;//In fact,when you are using the tcp/ip communication,this parameter will be ignored,that is any integer will all right.Here we use 1.
if (axCZKEM1.RegEvent(iMachineNumber, 65535))//Here you can register the realtime events that you want to be triggered(the parameters 65535 means registering all)
{
this.axCZKEM1.OnFinger += new zkemkeeper._IZKEMEvents_OnFingerEventHandler(axCZKEM1_OnFinger);
this.axCZKEM1.OnVerify += new zkemkeeper._IZKEMEvents_OnVerifyEventHandler(axCZKEM1_OnVerify);
this.axCZKEM1.OnAttTransactionEx += new zkemkeeper._IZKEMEvents_OnAttTransactionExEventHandler(axCZKEM1_OnAttTransactionEx);
this.axCZKEM1.OnFingerFeature += new zkemkeeper._IZKEMEvents_OnFingerFeatureEventHandler(axCZKEM1_OnFingerFeature);
this.axCZKEM1.OnEnrollFingerEx += new zkemkeeper._IZKEMEvents_OnEnrollFingerExEventHandler(axCZKEM1_OnEnrollFingerEx);
}
}

关于c# - ZKemKeeper 库中的实时事件处理程序在一段时间后停止响应设备事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32259022/

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