コード例 #1
0
        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;
        }
コード例 #2
0
        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"];
        }
コード例 #3
0
            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);
                }
            }