/// <summary>
        /// Free unmanaged resources
        /// </summary>
        /// <param name="disposing">Called from Dispose() flag</param>
        public void Dispose(bool disposing)
        {
            if (this.disposedValue)
            {
                return;
            }

            if (this.readerContext != IntPtr.Zero)
            {
                SmartcardInterop.SCardReleaseContext(this.readerContext);
            }

            this.disposedValue = true;
        }
        /// <summary>
        /// Create a new smartcard tracking context
        /// </summary>
        private void ResetContext()
        {
            this.logger.Debug("Resetting scard monitor context");
            if (this.readerContext != IntPtr.Zero)
            {
                SmartcardInterop.SCardReleaseContext(this.readerContext);
            }

            var result = SmartcardInterop.SCardEstablishContext(SmartcardInterop.Scope.User, IntPtr.Zero, IntPtr.Zero, out this.readerContext);

            if (result != SmartcardException.SCardSuccess)
            {
                this.logger.ErrorFormat("Failed to create smartcard context, result = 0x{0:X}", result);
                throw new SmartcardException(result);
            }

            this.cardNames    = this.FetchCards();
            this.readerNames  = this.FetchReaders();
            this.currentState = this.FetchState(this.readerNames);
        }