public CitiesCache(GeocoderApiInstance geocoderApi, ScheduleCityCodeApiInstance cityCodeApi, TimeSpan updateCachePeriod) { _cities = new List <Item>(); _geocoderApi = geocoderApi; _cityCodeApi = cityCodeApi; _syncRoot = new SingleConcurrencyBlock(); _timer = new Timer(UpdateCache, null, updateCachePeriod, updateCachePeriod); CacheLimit = 500; LastCacheUpdated = DateTime.Now; }
public EmailAlertsService(RepositoryFactory repositoryFactory, ScheduleThreadApiInstance scheduleThreadApi, UserManager <User> userManager, IConfiguration configuration) { _syncRoot = new SingleConcurrencyBlock(); _period = new TimeSpan(0, 1, 0); _timer = new Timer(TimerCallBack, null, _period, _period); RepositoryFactory = repositoryFactory; ScheduleThreadApi = scheduleThreadApi; ThreadsRepository = repositoryFactory.CreateThreads(); UserManager = userManager; _email = configuration["EmailDistributionSettings:Email"]; _password = configuration["EmailDistributionSettings:Password"]; }
public Token(SingleConcurrencyBlock block) { _block = block; Monitor.Enter(block._syncRoot); try { if (block._isProcessing) { Monitor.Wait(block._syncRoot); } block._isProcessing = true; } finally { Monitor.Exit(block._syncRoot); } }