public void ProcessJobsInBatches(Restriction restriction, bool applyManualSort, SortOrder sort, MapiTable contentsTable, MapiStore systemMbx, Func <MoveJob, bool> stoppingCondition)
        {
            List <MoveJob> allMoveJobs = SystemMailboxJobs.GetAllMoveJobs(restriction, sort, contentsTable, this.MdbGuid, stoppingCondition);

            if (allMoveJobs != null)
            {
                if (applyManualSort)
                {
                    allMoveJobs.Sort();
                }
                MrsTracer.Throttling.Debug("Sorted jobs for Mdb: {0}", new object[]
                {
                    this.MdbGuid
                });
                SystemMailboxJobs.TraceJobs(allMoveJobs);
                using (List <MoveJob> .Enumerator enumerator = allMoveJobs.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        MoveJob moveJob = enumerator.Current;
                        try
                        {
                            using (SettingsContextBase.ActivateContext(moveJob))
                            {
                                JobPickupRec pickupResult = null;
                                CommonUtils.CatchKnownExceptions(delegate
                                {
                                    pickupResult = moveJob.AttemptToPick(systemMbx);
                                    this.PerformPickupAccounting(moveJob.Status, pickupResult);
                                }, delegate(Exception failure)
                                {
                                    LocalizedString localizedString = CommonUtils.FullExceptionMessage(failure);
                                    pickupResult = new JobPickupRec(moveJob, JobPickupResult.PickupFailure, DateTime.UtcNow + MoveJob.JobPickupRetryInterval, localizedString, null);
                                    MrsTracer.Service.Error("Unexpected failure occurred trying to pick up MoveJob '{0}' from database '{1}', skipping it. {2}", new object[]
                                    {
                                        moveJob.RequestGuid,
                                        this.MdbGuid,
                                        localizedString
                                    });
                                    MailboxReplicationService.LogEvent(MRSEventLogConstants.Tuple_UnableToProcessRequest, new object[]
                                    {
                                        moveJob.RequestGuid.ToString(),
                                        this.MdbGuid.ToString(),
                                        localizedString
                                    });
                                });
                                this.ProcessPickupResults(pickupResult);
                            }
                        }
                        catch (Exception exception)
                        {
                            BaseJob.PerformCrashingFailureActions(moveJob.IdentifyingGuid, moveJob.RequestGuid, exception, RequestState.None, SyncStage.None);
                            throw;
                        }
                    }
                }
            }
        }