Net.Pkcs11Interop.HighLevelAPI.Pkcs11.Dispose C# (CSharp) Method

Dispose() protected method

Disposes object
protected Dispose ( bool disposing ) : void
disposing bool Flag indicating whether managed resources should be disposed
return void
        protected virtual void Dispose(bool disposing)
        {
            if (!this._disposed)
            {
                if (disposing)
                {
                    // Dispose managed objects
                    if (_p11_40 != null)
                    {
                        _p11_40.Dispose();
                        _p11_40 = null;
                    }

                    if (_p11_41 != null)
                    {
                        _p11_41.Dispose();
                        _p11_41 = null;
                    }

                    if (_p11_80 != null)
                    {
                        _p11_80.Dispose();
                        _p11_80 = null;
                    }

                    if (_p11_81 != null)
                    {
                        _p11_81.Dispose();
                        _p11_81 = null;
                    }
                }

                // Dispose unmanaged objects
                _disposed = true;
            }
        }

Same methods

Pkcs11::Dispose ( ) : void

Usage Example

 public void _01_BasicPkcs11DisposeTest()
 {
     // Unmanaged PKCS#11 library is loaded by the constructor of Pkcs11 class.
     // Every PKCS#11 library needs to be initialized with C_Initialize method
     // which is also called automatically by the constructor of Pkcs11 class.
     Pkcs11 pkcs11 = new Pkcs11(Settings.Pkcs11LibraryPath, Settings.UseOsLocking);
     
     // Do something  interesting
     
     // Unmanaged PKCS#11 library is unloaded by Dispose() method.
     // C_Finalize should be the last call made by an application and it
     // is also called automatically by Dispose() method.
     pkcs11.Dispose();
 }
All Usage Examples Of Net.Pkcs11Interop.HighLevelAPI.Pkcs11::Dispose