This class is NOT threadsafe, but is safe regarding multiple entries of the same thread ( main thread) which will is a common case when using async methods
Example #1
0
        public void SetOptions(Options[] options, bool checkIfOnline)
        {
            Dictionary <Guid, SynchronizationProfileRunner> workersById = new Dictionary <Guid, SynchronizationProfileRunner>();

            foreach (var option in options)
            {
                try
                {
                    SynchronizationProfileRunner profileRunner;
                    if (!_runnersById.TryGetValue(option.Id, out profileRunner))
                    {
                        profileRunner = new SynchronizationProfileRunner(
                            _synchronizerFactory,
                            _synchronizationReportRepository);
                    }
                    profileRunner.UpdateOptions(option, checkIfOnline);
                    workersById.Add(option.Id, profileRunner);
                }
                catch (Exception x)
                {
                    ExceptionHandler.Instance.LogException(x, s_logger);
                }
            }
            _runnersById = workersById;
        }
    public void SetUp ()
    {
      _synchronizerFactory = MockRepository.GenerateStub<ISynchronizerFactory>();
      _synchronizationProfileRunner = new SynchronizationProfileRunner (_synchronizerFactory);

      var options = new Options();
      _stubSynchronizer = new StubSynchronizer();
      _synchronizerFactory.Expect (f => f.CreateSynchronizer (options)).Return (_stubSynchronizer);
      _synchronizationProfileRunner.UpdateOptions (options);
    }
Example #3
0
        public async Task SetOptions(Options[] options, GeneralOptions generalOptions)
        {
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }
            if (generalOptions == null)
            {
                throw new ArgumentNullException(nameof(generalOptions));
            }

            Dictionary <Guid, SynchronizationProfileRunner> workersById = new Dictionary <Guid, SynchronizationProfileRunner>();

            foreach (var option in options)
            {
                try
                {
                    SynchronizationProfileRunner profileRunner;
                    if (!_runnersById.TryGetValue(option.Id, out profileRunner))
                    {
                        profileRunner = new SynchronizationProfileRunner(
                            _synchronizerFactory,
                            _reportSink,
                            _folderChangeWatcherFactory,
                            _ensureSynchronizationContext,
                            _runLogger,
                            DateTimeProvider.Instance,
                            option.Id);
                    }

                    await profileRunner.UpdateOptions(option, generalOptions);

                    workersById.Add(option.Id, profileRunner);
                }
                catch (Exception x)
                {
                    ExceptionHandler.Instance.LogException(x, s_logger);
                }
            }

            _runnersById = workersById;
        }
 public void SetOptions (Options[] options)
 {
   Dictionary<Guid, SynchronizationProfileRunner> workersById = new Dictionary<Guid, SynchronizationProfileRunner>();
   foreach (var option in options)
   {
     try
     {
       SynchronizationProfileRunner profileRunner;
       if (!_runnersById.TryGetValue (option.Id, out profileRunner))
         profileRunner = new SynchronizationProfileRunner (_synchronizerFactory);
       profileRunner.UpdateOptions (option);
       workersById.Add (option.Id, profileRunner);
     }
     catch (Exception x)
     {
       ExceptionHandler.Instance.LogException (x, s_logger);
     }
   }
   _runnersById = workersById;
 }
    public async Task SetOptions (Options[] options, GeneralOptions generalOptions)
    {
      if (options == null)
        throw new ArgumentNullException (nameof (options));
      if (generalOptions == null)
        throw new ArgumentNullException (nameof (generalOptions));

      Dictionary<Guid, SynchronizationProfileRunner> workersById = new Dictionary<Guid, SynchronizationProfileRunner>();
      foreach (var option in options)
      {
        try
        {
          SynchronizationProfileRunner profileRunner;
          if (!_runnersById.TryGetValue (option.Id, out profileRunner))
          {
            profileRunner = new SynchronizationProfileRunner (
                _synchronizerFactory,
                _reportSink,
                _folderChangeWatcherFactory,
                _ensureSynchronizationContext,
                _runLogger);
          }
          await profileRunner.UpdateOptions (option, generalOptions);
          workersById.Add (option.Id, profileRunner);
        }
        catch (Exception x)
        {
          ExceptionHandler.Instance.LogException (x, s_logger);
        }
      }
      _runnersById = workersById;
    }