Exemplo n.º 1
0
        protected virtual bool OnQueryRemove()
        {
            var e = new RemovableMediaEventArgs()
            {
                Drive = this.currentDrive, // drive which is hooked
            };

            QueryRemove?.Invoke(this, e);

            return(e.Cancel);
        }
Exemplo n.º 2
0
        public bool Remove()
        {
            _debugger.Trace();

            // Firing event, that might prevent device removal
            var e = new DeviceQueryRemoveEventArgs();

            QueryRemove?.Invoke(this, e);

            // Checking cancellation
            if (e.Cancel)
            {
                return(false);
            }

            // Unregistering and firing another event, that will notify all subscribers,
            // that device-removal is approved. This will help subscribers what to do next.
            Unregister();
            Removed?.Invoke(_deviceManager, new DeviceRemovedEventArgs(this));

            // ...
            return(true);
        }