コード例 #1
0
        /// <summary>
        /// Instantiates all configured providers.
        /// </summary>
        public void InstantiateProviders(string configSectionName)
        {
            _configSectionName = configSectionName;
            if (LogProvider != null)
            {
                LogProvider.Debug("Initializing " + (_configSectionName ?? ""));
            }
            try
            {
                _config = ConfigurationManager.GetSection(_configSectionName) as ProviderConfigurationSection;
                if (_config == null)
                {
                    throw new ProviderException(string.Format("'{0}' section missing.", _configSectionName));
                }
                if (_config.Providers == null || _config.Providers.Count == 0)
                {
                    throw new ProviderException(string.Format("No '{0}' providers have been configured.", _configSectionName));
                }

                ProvidersHelper.InstantiateProviders(_config.Providers, this, typeof(T));

                SetActiveProvider(_config.DefaultProvider);
            }
            catch (Exception ex)
            {
                if (LogProvider != null)
                {
                    LogProvider.Fatal("Could not Instantiate providers from configuration.", ex);
                }
                throw;
            }
        }
コード例 #2
0
 void mainTimer__Elapsed(object sender)
 {
     lock (_iterationLock)
     {
         try
         {
             PauseTimer();
             LogProvider.Debug("WorkerRole is still alive.");
             foreach (WorkerRoleTask task in _tasks)
             {
                 task.Ping();
             }
         }
         catch (Exception ex)
         {
             LogProvider.Error("WorkerRole failed to ping.", ex);
         }
         finally
         {
             try
             {
                 ResumeTimer();
             }
             catch (Exception ex)
             {
                 LogProvider.Error("WorkerRole could not resume the timer.", ex);
                 if (IsRunning)
                 {
                     ResetTimer();
                 }
             }
         }
     }
 }
コード例 #3
0
 private void Dispose(bool disposing)
 {
     if (!_disposed)
     {
         LogProvider.Debug("Disposing worker role.");
         OnStop();
         foreach (var task in _tasks.OfType <IDisposable>())
         {
             (task).Dispose();
         }
         LogProvider.Debug("Disposed worker role.");
     }
     _disposed = true;
 }
コード例 #4
0
 public static void Debug(String msg)
 {
     LogProvider.Debug(msg);
 }