示例#1
0
 protected virtual void Dispose(bool disposing)
 {
     if (!_disposed)
     {
         if (disposing)
         {
             this.DisconnectAll();
             _threadPool         = null;
             _sessionManagers    = null;
             _contextLookupTable = null;
         }
         _disposed = true;
     }
 }
示例#2
0
        /// <summary>
        /// Initializes a new instance of the AddressBookConnectionManager class
        /// </summary>
        public AddressBookConnectionManager()
        {
            /*
             * create the thread pool that will help us during connection and disconnection attempts
             * */
            _threadPool = new BackgroundThreadPool();

            /*
             * create a new list for storing connection managers
             * */
            _sessionManagers = new AddressBookItemConnectionManagerList();

            /*
             * create a new context lookup table to allow pre-binding of contexts to items
             * */
            _contextLookupTable = new Hashtable();
        }
示例#3
0
        /// <summary>
        /// This method is called when the app pool starts
        /// </summary>
        public static void InitialLoadConfiguration()
        {
            InternalReloadSiteHostCache();

            List <cmSite> sites         = null;
            SiteRouteInfo siteRouteInfo = null;

            bool preloadRoot = ConfigurationManager.AppSettings["Init.PreloadRootTemplateSiteRouteInfo"].DefaultIfNullOrWhiteSpace("false").Equals("true", StringComparison.InvariantCultureIgnoreCase);

            if (preloadRoot)
            {
                // Load Root Template Sites' RouteInfo
                sites = GetRootTemplateSites();
                {
                    foreach (cmSite site in sites)
                    {
                        siteRouteInfo = new SiteRouteInfo(site);
                        LoadSiteRouteInfo(siteRouteInfo);
                    }
                }
                sites = GetSites().Where(s => !sites.Exists(rs => rs.ID == s.ID)).ToList();
            }
            else
            {
                sites = GetSites();
            }

            if (!string.IsNullOrWhiteSpace(ConfigurationManager.AppSettings["Init.Debug.Sites"]))
            {
                //only loads the sites specificed from web.config & template sites, to speed the loading for debug
                sites = GetSites().Where(s => GetRootTemplateSites().Exists(ts => ts.ID == s.ID) || GetDebugSites().Contains(s.ID)).ToList();
            }

            foreach (cmSite site in sites)
            {
                siteRouteInfo = new SiteRouteInfo(site);
                s_DistinctName2DomainRouteInfo[site.DistinctName] = siteRouteInfo;

                BackgroundThreadPool.QueueUserWorkItem("InitialLoadConfiguration", new WaitCallback(LoadSiteRouteInfo), siteRouteInfo, true);
            }
        }
        internal void ExecuteInternal()
        {
            if (Status == WorkerServiceStatus.Stopped ||
                Status == WorkerServiceStatus.Stopping ||
                Status == WorkerServiceStatus.Running ||
                Status == WorkerServiceStatus.Faulted)
            {
                return;
            }

            if (Status == WorkerServiceStatus.Sleeping)
            {
                BackgroundThreadPool.Enqueue(() =>
                {
                    try
                    {
                        Status = WorkerServiceStatus.Running;
                        _instance.Execute(_context);
                        if (Status == WorkerServiceStatus.Running)
                        {
                            Status = WorkerServiceStatus.Sleeping;
                        }
                        else if (Status == WorkerServiceStatus.Stopping)
                        {
                            Status = WorkerServiceStatus.Stopped;
                        }
                    }
                    catch (Exception ex)
                    {
                        _context.Logger.LogException("Error on execute service", ex, Priority.High);
                        _errors.Add(ex);
                        Status = WorkerServiceStatus.Faulted;
                    }
                });
            }
        }
示例#5
0
 public static void UpdateToLatest()
 {
     BackgroundThreadPool.QueueUserWorkItem("DownloadGeoIPDatabase", new WaitCallback(DownloadGeoIPDatabase), null, true);
 }
 public static void Begin()
 {
     BackgroundThreadPool.QueueUserWorkItem("ScalableThumbnailProcessor", ProcessScalableThumbnails, null);
 }
示例#7
0
 public static void Init()
 {
     BackgroundThreadPool.QueueUserWorkItem("ChangeNotifier", LongRunThread, null);
 }