C_WaitForSlotEvent() public method

Waits for a slot event, such as token insertion or token removal, to occur
public C_WaitForSlotEvent ( uint flags, uint &slot, IntPtr reserved ) : CKR
flags uint Determines whether or not the C_WaitForSlotEvent call blocks (i.e., waits for a slot event to occur)
slot uint Location which will receive the ID of the slot that the event occurred in
reserved System.IntPtr Reserved for future versions (should be null)
return CKR
        public void _03_WaitForSlotEventTest()
        {
            if (Platform.UnmanagedLongSize != 4 || Platform.StructPackingSize != 0)
                Assert.Inconclusive("Test cannot be executed on this platform");

            CKR rv = CKR.CKR_OK;
            
            using (Pkcs11 pkcs11 = new Pkcs11(Settings.Pkcs11LibraryPath))
            {
                rv = pkcs11.C_Initialize(Settings.InitArgs40);
                if ((rv != CKR.CKR_OK) && (rv != CKR.CKR_CRYPTOKI_ALREADY_INITIALIZED))
                    Assert.Fail(rv.ToString());

                // Wait for a slot event
                uint slot = 0;
                rv = pkcs11.C_WaitForSlotEvent(CKF.CKF_DONT_BLOCK, ref slot, IntPtr.Zero);
                if (rv != CKR.CKR_NO_EVENT)
                    Assert.Fail(rv.ToString());

                rv = pkcs11.C_Finalize(IntPtr.Zero);
                if (rv != CKR.CKR_OK)
                    Assert.Fail(rv.ToString());
            }
        }