// Aguarda um evento no PIN-pad
        public E_PWPPEVT WaitEventOnPP(E_PWPPEVTIN events)
        {
            int  ret;
            uint eventOut = (uint)events;

            // Executa o comando que inicia a espera por evento no PIN-pad
            ret = Interop.PW_iPPWaitEvent(ref eventOut);

            // Registra na janela de debug o comando
            Debug.Print(string.Format("PW_iPPWaitEvent({0}{1}={2}", events, eventOut,
                                      ret.ToString()));

            // Caso tenha ocorrido algum erro, retorna
            if (ret != (int)E_PWRET.PWRET_OK)
            {
                return(E_PWPPEVT.PWPPEVT_NONE);
            }

            // Entra no loop aguardando a finalização do comando
            ret = LoopPP();

            // Registra na janela de debug o retorno do loop
            Debug.Print(string.Format("Retorno={0}", ret.ToString()));

            // Caso tenha ocorrido algum erro, retorna
            if (ret != (int)E_PWRET.PWRET_OK)
            {
                return(E_PWPPEVT.PWPPEVT_NONE);
            }

            return((E_PWPPEVT)eventOut);
        }
        // Aguarda qualquer evento que ocorra no PIN-pad
        private void btnWaitEvent_Click(object sender, RoutedEventArgs e)
        {
            E_PWPPEVTIN eventoEntrada = E_PWPPEVTIN.PWPPEVTIN_ICC | E_PWPPEVTIN.PWPPEVTIN_ICCOUT |
                                        E_PWPPEVTIN.PWPPEVTIN_CTLS | E_PWPPEVTIN.PWPPEVTIN_KEYS | E_PWPPEVTIN.PWPPEVTIN_MAG;
            E_PWPPEVT eventoSaida;

            // Inicia a espera por todos os eventos possíveis
            eventoSaida = eft.WaitEventOnPP(eventoEntrada);
            if (eventoSaida != E_PWPPEVT.PWPPEVT_NONE)
            {
                MessageBox.Show(this, string.Format("Evento acionado={0}", eventoSaida.ToString()));
                return;
            }
        }