ZkemKeeper事件未被触发

时间:2017-10-03 07:58:53

标签: c# windows-applications

我在ZkemKeeper下面有这个代码。

private void btnMachine1_Click(object sender, EventArgs e)
        {
            iMachineNumber = 1;
            ip = "192.168.1.201";
            port = 4370;
            int idwErrorCode = 0;

            Cursor = Cursors.WaitCursor;

            if (btnMachine1.Text == "DisConnect")
            {
                axCZKEM1.Disconnect();
                this.axCZKEM1.OnVerify -= new zkemkeeper._IZKEMEvents_OnVerifyEventHandler(axCZKEM1_OnVerify);
                this.axCZKEM1.OnAttTransactionEx -= new zkemkeeper._IZKEMEvents_OnAttTransactionExEventHandler(axCZKEM1_OnAttTransactionEx);

                bIsConnected = false;
                btnMachine1.Text = "Connect";
                lblStatus1.Text = "Current State:DisConnected";
                Cursor = Cursors.Default;
                return;
            }

            bIsConnected = zkepeerClass.Connect_Net(ip, port);
            if (bIsConnected == true)
            {
                btnMachine1.Text = "DisConnect";
                btnMachine1.Refresh();
                lblStatus1.Text = "Current State:Connected";
                iMachineNumber = 2;//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.OnVerify += new zkemkeeper._IZKEMEvents_OnVerifyEventHandler(axCZKEM1_OnVerify);
                    this.axCZKEM1.OnAttTransactionEx += new zkemkeeper._IZKEMEvents_OnAttTransactionExEventHandler(axCZKEM1_OnAttTransactionEx);

                }

            }
                else
            {
                axCZKEM1.GetLastError(ref idwErrorCode);
                MessageBox.Show("Unable to connect the device,ErrorCode=" + idwErrorCode.ToString(), "Error");
            }

            Cursor = Cursors.Default;

        }

匹配正在连接。但事件没有被触发。当我调试时,我发现事件没有被注册。表示此代码块无效。

 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.OnVerify += new zkemkeeper._IZKEMEvents_OnVerifyEventHandler(axCZKEM1_OnVerify);
                    this.axCZKEM1.OnAttTransactionEx += new zkemkeeper._IZKEMEvents_OnAttTransactionExEventHandler(axCZKEM1_OnAttTransactionEx);

                }

我搜索了有关此问题的答案,但找不到任何解决方法。我是新的。请建议我的解决方案。感谢。

0 个答案:

没有答案