novotnyllc / MiFare

MiFare Classic support for UWP and Windows Desktop apps
MIT License
37 stars 29 forks source link

MiFare.CardReader.FindAsync is not async and cannot be awaited #14

Open Bobilas opened 2 years ago

Bobilas commented 2 years ago

If you attempt calling SmartCardReader reader = await CardReader.FindAsync() and no card reader is connected, you will get "System.NullReferenceException: Object reference not set to an instance of an object.", because it attempts to await null. It should either return Task.FromResult(null), or be rewritten so it's actually async.

The workaround I had to use is SmartCardReader reader = CardReader.FindAsync()?.Result;