{"action":"created","issue":{"url":"https://api.github.com/repos/danm-de/pcsc-sharp/issues/30","repository_url":"https://api.github.com/repos/danm-de/pcsc-sharp","labels_url":"https://api.github.com/repos/danm-de/pcsc-sharp/issues/30/labels{/name}","comments_url":"https://api.github.com/repos/danm-de/pcsc-sharp/issues/30/comments","events_url":"https://api.github.com/repos/danm-de/pcsc-sharp/issues/30/events","html_url":"https://github.com/danm-de/pcsc-sharp/issues/30","id":164563384,"number":30,"title":"Detect cards already present before Monitor Start()","user":{"login":"Philekunf","id":20358997,"avatar_url":"https://avatars.githubusercontent.com/u/20358997?v=3","gravatar_id":"","url":"https://api.github.com/users/Philekunf","html_url":"https://github.com/Philekunf","followers_url":"https://api.github.com/users/Philekunf/followers","following_url":"https://api.github.com/users/Philekunf/following{/other_user}","gists_url":"https://api.github.com/users/Philekunf/gists{/gist_id}","starred_url":"https://api.github.com/users/Philekunf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Philekunf/subscriptions","organizations_url":"https://api.github.com/users/Philekunf/orgs","repos_url":"https://api.github.com/users/Philekunf/repos","events_url":"https://api.github.com/users/Philekunf/events{/privacy}","received_events_url":"https://api.github.com/users/Philekunf/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-07-08T16:05:45Z","updated_at":"2016-07-08T20:56:05Z","closed_at":null,"body":"Hi Daniel!\r\n\r\nFirst let me thank you for a wonderful library, I was using a poorly implemented library before this one and since I needed to run some heavy modifications to my NfcController class, I opted to switch to this one first. I am also considering forking and submitting a few pull requests here if you find them pertinent.\r\n\r\nThis issue concerns the SCardMonitor class which does not fire a CardFound Event on load if a card is already present on the reader. I don't recall exactly how the events did it in the previous library I used but this is one of the few features it had over this one.\r\n\r\nBasically when my software launches, it cannot read a card that was already on the reader until I remove and reapproach it. That is partly my fault, as it would probably work to connect and transmit to the card but I am using a bool variable on the CardFound and CardRemoved events to prevent even trying.\r\n\r\nIs there a way currently to know a card is present at initialization time from either the SCardReader or SCardMonitor?\r\n\r\nHere is a sample of my code\r\n\r\n```\r\n    public class NfcController: IDisposable\r\n    {\r\n        public NfcController() \r\n        {\r\n            _context = new SCardContext();\r\n            _context.Establish(SCardScope.System);\r\n            var readerList = _context.GetReaders().ToList();\r\n            if (!readerList.Any()) throw new ApplicationException(\"Could not initialize NFC reader.\");\r\n            _readerName = readerList[DEFAULT_READER];\r\n            _reader = new SCardReader(_context);\r\n            _reader.ApduSent += OnApduSent;\r\n            _reader.ApduReceived += OnApduReceived;\r\n\r\n            _monitor = new SCardMonitor(_context, SCardScope.System);\r\n            _monitor.CardInserted += OnCardFound;\r\n            _monitor.CardRemoved += OnCardRemoved;\r\n            _monitor.MonitorException += OnError;\r\n            _monitor.Start(new[] { _readerName });\r\n\r\n            //todo: trigger initial cardFound event.\r\n            //Not working\r\n            if (_monitor.GetCurrentState(0) == ScrState.Present) //Current state on load is \"Unaware\" :(\r\n            {\r\n                //do something!\r\n            }\r\n        }\r\n\r\n        //...\r\n        private const int DEFAULT_READER = 0x00;\r\n        private readonly SCardMonitor _monitor;\r\n        private readonly SCardReader _reader;\r\n        private readonly SCardContext _context;\r\n        //...\r\n    }\r\n```"},"comment":{"url":"https://api.github.com/repos/danm-de/pcsc-sharp/issues/comments/231470521","html_url":"https://github.com/danm-de/pcsc-sharp/issues/30#issuecomment-231470521","issue_url":"https://api.github.com/repos/danm-de/pcsc-sharp/issues/30","id":231470521,"user":{"login":"Philekunf","id":20358997,"avatar_url":"https://avatars.githubusercontent.com/u/20358997?v=3","gravatar_id":"","url":"https://api.github.com/users/Philekunf","html_url":"https://github.com/Philekunf","followers_url":"https://api.github.com/users/Philekunf/followers","following_url":"https://api.github.com/users/Philekunf/following{/other_user}","gists_url":"https://api.github.com/users/Philekunf/gists{/gist_id}","starred_url":"https://api.github.com/users/Philekunf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Philekunf/subscriptions","organizations_url":"https://api.github.com/users/Philekunf/orgs","repos_url":"https://api.github.com/users/Philekunf/repos","events_url":"https://api.github.com/users/Philekunf/events{/privacy}","received_events_url":"https://api.github.com/users/Philekunf/received_events","type":"User","site_admin":false},"created_at":"2016-07-08T20:56:05Z","updated_at":"2016-07-08T20:56:05Z","body":"I never noticed the Initalized event while going through the source code!\r\nI will be trying both of these solutions first thing monday morning and report back.\r\n\r\nThank you for the swift reply,\r\nPhil~"}}
{"actor":{"display_login":"Philekunf"}}