private void ScanThread(string[] rootPaths, CancellationToken token)
        {
            Exception exception = null;

            try {
                Scan(rootPaths, token);
            }
            catch (Exception ex) {
                exception = ex;
            }
            finally {
                ProgressState = ScanProgressState.Ending;
                cancel?.Dispose();
                cancel = null;
                watch?.Stop();
                scanThread = null;

                if (!disposed)
                {
                    RaisePropertyChanged(nameof(ScanTime));
                    if (scanState == ScanState.Cancelling)
                    {
                        RootNode  = null;
                        ScanState = ScanState.Cancelled;
                    }
                    else if (exception == null)
                    {
                        ScanState = ScanState.Finished;
                    }
                    else
                    {
                        ScanState = ScanState.Failed;
                    }
                    ProgressState = ScanProgressState.Ended;
                    ScanEnded?.Invoke(this, new ScanEventArgs(scanState, progressState, exception));
                    if (scanState == ScanState.Cancelled)
                    {
                        ScanCancelled?.Invoke(this, new ScanEventArgs(scanState, progressState, exception));
                        ScanCancelled = null;
                    }
                }
            }
        }
Beispiel #2
0
 internal void RaiseScanEndedEvent(ScanEndedEventArgs e)
 {
     ScanEnded?.Invoke(this, e);
 }