public void Run() { if (running.IsCancellationRequested) { return; } Checkpoint projectionСhangeCheckpoint = checkpoints.Load(Checkpoint.PROJECTION_CHANGE); Checkpoint regularCheckpoint = checkpoints.Load(Checkpoint.REGULAR); IProjection[] projections = ioc.ResolveAll <IProjection>().ToArray(); // If regular checkpoint is undefined rebuild all projections if (regularCheckpoint.IsUndefined) { MarkAsUnmodified(projections); } else { // 1. Update changed projection ONLY up to regular checkpoint var modifiedProjections = versioningRepository.SelectModified(projections); if (modifiedProjections.Any()) { ShowProjectionsToRebuild(modifiedProjections); Rebuild(projectionСhangeCheckpoint, regularCheckpoint, modifiedProjections); if (running.IsCancellationRequested) { return; } MarkAsUnmodified(modifiedProjections); } } // 2. Replay commit's tail for all projections Rebuild(regularCheckpoint, new Checkpoint(Checkpoint.REGULAR), projections); if (running.IsCancellationRequested) { return; } // 3. Replay commit's tail again to handle events which was fired during rebuild Rebuild(regularCheckpoint, new Checkpoint(Checkpoint.REGULAR), projections); }