Beispiel #1
0
        protected virtual void Dispose(bool disposing)
        {
            if (!this.disposed)
            {
                try {
                    RegisterForDeviceChange(false, null);
                } catch { }

                if (disposing)
                {
                    this.fileOnFlash?.Close();
                    if (this.hwnd != null)
                    {
                        this.hwnd.RemoveHook(WndProc);
                    }
                    this.window?.Dispatcher.Invoke(() => {
                        this.window.Close();
                    });
                }

                this.disposed    = true;
                this.fileOnFlash = null;
                this.hwnd        = null;
                this.window      = null;
            }
        }
Beispiel #2
0
        /// <summary>
        /// Creates a hidden window for processing Windows messages about
        /// removable drives.
        /// </summary>
        public RemovableDriveManager()
        {
            this.window = new DetectorWindow();
            this.window.Show();
            this.hwnd = (HwndSource)PresentationSource.FromVisual(this.window);

            Initialize(null);
        }