Net.Pkcs11Interop.LowLevelAPI81.Pkcs11.C_WaitForSlotEvent C# (CSharp) Method

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
        public CKR C_WaitForSlotEvent(ulong flags, ref ulong slot, IntPtr reserved)
        {
            if (this._disposed)
                throw new ObjectDisposedException(this.GetType().FullName);

            ulong rv = _delegates.C_WaitForSlotEvent(flags, ref slot, reserved);
            return (CKR)Convert.ToUInt32(rv);
        }

Usage Example

コード例 #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());
            }
        }