Esempio n. 1
0
        public SL600SDK CreateInstance()
        {
            lock (_syncObj)
            {
                if (_hModule == IntPtr.Zero)
                {
                    _hModule = Win32Interop.LoadLibraryExW(_pathToDll, IntPtr.Zero, 0x00001000);
                    if (_hModule == IntPtr.Zero)
                    {
                        Win32Interop.GetLastErrorAndThrow();
                    }
                }

                if (_thread == null)
                {
                    _thread = new DispathcedThread();
                }

                if (_functions == null)
                {
                    _functions = new FunctionPointersContainer(_hModule);
                }

                var inst = new SL600SDK(_thread, _functions);
                inst.Disposed += Inst_Disposed;
                Interlocked.Increment(ref _refCounter);
                return(inst);
            }
        }
Esempio n. 2
0
 private void Release()
 {
     lock (_syncObj)
     {
         _thread.Dispose();
         _thread    = null;
         _functions = null;
         Win32Interop.FreeLibrary(_hModule);
         _hModule = IntPtr.Zero;
     }
 }
Esempio n. 3
0
        protected virtual void Dispose(bool disposing)
        {
            if (!disposedValue)
            {
                if (disposing)
                {
                    // TODO: освободить управляемое состояние (управляемые объекты).
                }

                _thread    = null;
                _functions = null;

                disposedValue = true;

                Disposed?.Invoke(this, new EventArgs());
            }
        }
Esempio n. 4
0
 internal SL600SDK(DispathcedThread thread, FunctionPointersContainer functions)
 {
     _thread    = thread;
     _functions = functions;
 }