コード例 #1
0
        protected override void StatusChangeMonitor()
        {
            uint state = 0;

            while (_status_change_running)
            {
                uint rc;

                try {
                    rc = ParentReaderList.GetStatusChange(ReaderSlot, ref state, 250);
                }
                catch (ThreadInterruptedException) {
                    break;
                }

                if (!_status_change_running)
                {
                    break;
                }

                if (rc == SCARD.E_TIMEOUT)
                {
                    continue;
                }

                if (rc != SCARD.S_SUCCESS)
                {
                    _last_error = rc;
                    if (_status_change_callback != null)
                    {
                        _status_change_callback(0, null);
                    }
                    break;
                }

                if ((state & SCARD.STATE_CHANGED) != 0)
                {
                    state = state & ~SCARD.STATE_CHANGED;

                    if (_status_change_callback != null)
                    {
                        CardBuffer card_atr = null;

                        if ((state & SCARD.STATE_PRESENT) != 0)
                        {
                            card_atr = new CardBuffer(ParentReaderList.GetAtr(ReaderSlot));
                        }

                        _status_change_callback(state, card_atr);
                    }
                }
            }
        }
コード例 #2
0
 protected override void UpdateState()
 {
     _reader_state = ReaderDevice.State(Slot);
     Logger.Debug("UpdateState:" + BinConvert.ToHex(_reader_state));
     if ((_reader_state & SCARD.STATE_PRESENT) != 0)
     {
         _card_atr = new CardBuffer(ReaderDevice.GetAtr(Slot));
     }
     else
     {
         _card_atr = null;
     }
 }