I set up pkcs11Interop Library as follows
Pkcs11Library = PkcsFactories.Pkcs11LibraryFactory.LoadPkcs11Library(PkcsFactories, pkcs11LibraryPath, AppType.MultiThreaded)
I then immediately use a WPF DispatcherTimer which contains the WaitForSlotEvent
Private Sub CardInsertedTimer_Tick(sender As Object, e As EventArgs)
Dim eventHappened As Boolean
Dim id As ULong
Pkcs11Library.WaitForSlotEvent(WaitType.NonBlocking, eventHappened, id)
If eventHappened Then
Debug.Print("CardInsertedEvent - Event - Event: " + eventHappened.ToString + " ID: " + id.ToString)
End If
End Sub
I hope there are no surprises here. If the Slot (which is a USB smart card reader) is removed then I get a C_WaitForSlotEvent returned CKR_DEVICE_ERROR.
- Is a DispatcherTimer ok for WaitForSlotEvent?
- What should I do to avoid C_WaitForSlotEvent CKR_DEVICE_ERROR?
- Does pkcs11Interop handle the adding and removing of slots (ie. SmartCard Readers)?
- If pkcs11Interop does not handle adding and removing slots is polling the only way and what would be the best to poll?