C_WaitForSlotEvent() public method

Waits for a slot event, such as token insertion or token removal, to occur
public C_WaitForSlotEvent ( ulong flags, ulong &slot, IntPtr reserved ) : CKR
flags ulong Determines whether or not the C_WaitForSlotEvent call blocks (i.e., waits for a slot event to occur)
slot ulong 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
コード例 #1
0
        public void _03_WaitForSlotEventTest()
        {
            if (Platform.UnmanagedLongSize != 8 || Platform.StructPackingSize != 1)
                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.InitArgs81);
                if ((rv != CKR.CKR_OK) && (rv != CKR.CKR_CRYPTOKI_ALREADY_INITIALIZED))
                    Assert.Fail(rv.ToString());

                // Wait for a slot event
                ulong 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());
            }
        }