public IFileDatabase Build(
      IFileDatabase previousFileDatabase,
      FileSystemTreeSnapshot newSnapshot,
      FullPathChanges fullPathChanges,
      Action<IFileDatabase> onIntermadiateResult) {
      using (var logger = new TimeElapsedLogger("Building file database from previous one and file system tree snapshot")) {

        var fileDatabase = (FileDatabase)previousFileDatabase;

        // Compute list of files from tree
        ComputeFileCollection(newSnapshot);

        var unchangedProjects = newSnapshot
          .ProjectRoots.Where(x =>
            fileDatabase.ProjectHashes.ContainsKey(x.Project.RootPath) &&
            fileDatabase.ProjectHashes[x.Project.RootPath] == x.Project.VersionHash)
          .Select(x => x.Project);

        var unchangedProjectSet = new HashSet<IProject>(unchangedProjects,
          // Use reference equality for IProject is safe, as we keep this
          // dictionary only for the duration of this "Build" call.
          new ReferenceEqualityComparer<IProject>());

        // Don't use file memoization for now, as benefit is dubvious.
        //IFileContentsMemoization fileContentsMemoization = new FileContentsMemoization();
        IFileContentsMemoization fileContentsMemoization = new NullFileContentsMemoization();

        var loadingInfo = new FileContentsLoadingInfo {
          FileContentsMemoization = fileContentsMemoization,
          FullPathChanges = fullPathChanges,
          LoadedTextFileCount = 0,
          OldFileDatabase = fileDatabase,
          UnchangedProjects = unchangedProjectSet,
          PartialProgressReporter = new PartialProgressReporter(
            TimeSpan.FromSeconds(5.0),
            () => {
              Logger.LogInfo("Creating intermedidate file database");
              var database = this.CreateFileDatabse();
              onIntermadiateResult(database);
            })
        };

        // Merge old state in new state and load all missing files
        LoadFileContents(loadingInfo);

        return CreateFileDatabse();
      }
    }
        public IFileDatabase Build(
            IFileDatabase previousFileDatabase,
            FileSystemTreeSnapshot newSnapshot,
            FullPathChanges fullPathChanges,
            Action <IFileDatabase> onIntermadiateResult)
        {
            using (var logger = new TimeElapsedLogger("Building file database from previous one and file system tree snapshot")) {
                var fileDatabase = (FileDatabase)previousFileDatabase;

                // Compute list of files from tree
                ComputeFileCollection(newSnapshot);

                var unchangedProjects = newSnapshot
                                        .ProjectRoots.Where(x =>
                                                            fileDatabase.ProjectHashes.ContainsKey(x.Project.RootPath) &&
                                                            fileDatabase.ProjectHashes[x.Project.RootPath] == x.Project.VersionHash)
                                        .Select(x => x.Project);

                var unchangedProjectSet = new HashSet <IProject>(unchangedProjects,
                                                                 // Use reference equality for IProject is safe, as we keep this
                                                                 // dictionary only for the duration of this "Build" call.
                                                                 new ReferenceEqualityComparer <IProject>());

                // Don't use file memoization for now, as benefit is dubvious.
                //IFileContentsMemoization fileContentsMemoization = new FileContentsMemoization();
                IFileContentsMemoization fileContentsMemoization = new NullFileContentsMemoization();

                var loadingInfo = new FileContentsLoadingInfo {
                    FileContentsMemoization = fileContentsMemoization,
                    FullPathChanges         = fullPathChanges,
                    LoadedTextFileCount     = 0,
                    OldFileDatabase         = fileDatabase,
                    UnchangedProjects       = unchangedProjectSet,
                    PartialProgressReporter = new PartialProgressReporter(
                        TimeSpan.FromSeconds(5.0),
                        () => {
                        Logger.LogInfo("Creating intermedidate file database");
                        var database = this.CreateFileDatabse();
                        onIntermadiateResult(database);
                    })
                };

                // Merge old state in new state and load all missing files
                LoadFileContents(loadingInfo);

                return(CreateFileDatabse());
            }
        }