Exemplo n.º 1
0
        private void MountLoop()
        {
            while (true)
            {
                Debug.WriteLine("Thread:Pause");

                _pauseEvent.WaitOne(-1);
                if (_threadCancel.IsCancellationRequested)
                {
                    Debug.WriteLine("Thread:Cancel");
                    break;
                }

                Debug.WriteLine("Thread:Mount");


                try
                {
                    _filesystem.Mount(String.Format("{0}:\\", Letter),
                                      DokanOptions.NetworkDrive | DokanOptions.KeepAlive);
                }
                catch (Exception e)
                {
                    _lastExeption   = e;
                    _exeptionThrown = true;
                    _mountCancel.Cancel();
                }
                Status = DriveStatus.Unmounted;
                if (!_exeptionThrown)
                {
                    OnStatusChanged(EventArgs.Empty);
                }
            }
        }
Exemplo n.º 2
0
        private void MountLoop()
        {
            while (true)
            {
                Debug.WriteLine("Thread:Pause");

                _pauseEvent.WaitOne(-1);
                if (_threadCancel.IsCancellationRequested)
                {
                    Debug.WriteLine("Thread:Cancel");
                    break;
                }

                Debug.WriteLine("Thread:Mount");

                try
                {
                    int threadCount = 32;
#if DEBUG
                    threadCount = 1;
#endif
                    _filesystem.Mount($"{Letter}:\\",
                                      Settings.Default.UseNetworkDrive ? DokanOptions.NetworkDrive : DokanOptions.RemovableDrive,
                                      threadCount);
                }
                catch (Exception e)
                {
                    _lastExeption   = e;
                    _exeptionThrown = true;
                    _mountCancel.Cancel();
                }

                Status = DriveStatus.Unmounted;
                if (!_exeptionThrown)
                {
                    OnStatusChanged(EventArgs.Empty);
                }
            }
        }