CalDavSynchronizer.Scheduling.SynchronizationProfileRunner.RunAllPendingJobs C# (CSharp) Метод

RunAllPendingJobs() приватный Метод

private RunAllPendingJobs ( ) : Task
Результат Task
    private async Task RunAllPendingJobs ()
    {
      if (_checkIfOnline && !ConnectionTester.IsOnline (_proxyOptions))
      {
        s_logger.WarnFormat ("Skipping synchronization profile '{0}' (Id: '{1}') because network is not available", _profileName, _profileId);
        return;
      }

      // Monitor cannot be used here, since Monitor allows recursive enter for a thread 
      if (Interlocked.CompareExchange (ref _isRunning, 1, 0) == 0)
      {
        try
        {
          while (_fullSyncPending || _pendingOutlookItems.Count > 0)
          {
            if (_fullSyncPending)
            {
              _fullSyncPending = false;
              Thread.MemoryBarrier(); // should not be required because there is just one thread entering multiple times
              await RunAndRescheduleNoThrow();
            }

            if (_pendingOutlookItems.Count > 0)
            {
              var itemsToSync = _pendingOutlookItems.Values.ToArray();
              _pendingOutlookItems.Clear();
              if (s_logger.IsDebugEnabled)
              {
                s_logger.Debug ($"Partial sync: Going to sync '{itemsToSync.Length}' pending items ( {string.Join (", ", itemsToSync.Select (id => id.EntryId))} ).");
              }
              Thread.MemoryBarrier(); // should not be required because there is just one thread entering multiple times
              await RunPartialNoThrow (itemsToSync);
            }
          }
        }
        finally
        {
          Interlocked.Exchange (ref _isRunning, 0);
        }
      }
    }