当前位置: 首页>>代码示例>>C#>>正文


C# IScheduler.Register方法代码示例

本文整理汇总了C#中IScheduler.Register方法的典型用法代码示例。如果您正苦于以下问题:C# IScheduler.Register方法的具体用法?C# IScheduler.Register怎么用?C# IScheduler.Register使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IScheduler的用法示例。


在下文中一共展示了IScheduler.Register方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Open

 public void Open(int timeout)
 {
     //已OPEN的,不再OPEN,多线程处理
     if (IsHasOpen) return;
     if (ConfigUtil.Instance.ConnectionCount > 0)
         ServicePointManager.DefaultConnectionLimit = ConfigUtil.Instance.ConnectionCount;
     ConfigUtil.Instance.NotifyPropertyChange += (type) =>
                                                     {
                                                         switch (type)
                                                         {
                                                             case NotifyProperty.ConnectionCount:
                                                                 if (ConfigUtil.Instance.ConnectionCount > 0)
                                                                     ServicePointManager.DefaultConnectionLimit =
                                                                         ConfigUtil.Instance.ConnectionCount;
                                                                 break;
                                                             default:
                                                                 break;
                                                         }
                                                     };
     if (IsNoExistFxConfig)
     {
         IDictionary<string, string> settings = SettingsUtils.GetAppSettings();
         string configServiceUri = "";
         if (settings.ContainsKey("CmessageServiceUri"))
             configServiceUri = settings["CmessageServiceUri"];
         if (string.IsNullOrEmpty(configServiceUri))
         {
             throw new Exception("Must config 'CmessageServiceUri' OR 'FxConfigServiceUrl' in appSettings.");
         }
     }
     if(SyncScheduler==null)
     {
         SyncScheduler = ObjectFactory.Current.Get<IScheduler>(Lifetime.ContainerControlled);
         SyncScheduler.Register(SyncServers, "cmessaging.producer.defaultmessagechannel.syncconfig", 60 * 1000, false);
     }
     if(!IsNoExistFxConfig)
     {
         ConfigUtil.Instance.RunScheduler();//v1.0启动同步
     }
 }
开发者ID:sdgdsffdsfff,项目名称:hermes.net,代码行数:40,代码来源:DefaultMessageChannel.cs

示例2: RunScheduler

        public void RunScheduler()
        {
            if (SyncMetadataScheduler != null) return;
            SyncMetadataScheduler = ObjectFactory.Current.Get<IScheduler>(Lifetime.ContainerControlled);
            //每隔一分钟刷新一次
            SyncMetadataScheduler.Register(() =>
            {
                int isSuccess = 1;
                try
                {
                    var fxConfigServiceUrl = ConfigurationManager.AppSettings["FxConfigServiceUrl"];
                    if (string.IsNullOrEmpty(fxConfigServiceUrl))
                    {
                        //MetricManagerFactory.MetricManager.Set(new ExceptionCountMetric() { HappenedWhere = ExceptionType.OnMetadataSync.ToString() });
                        return;
                    }

                    CmessagingAdminUrl = CentralConfig.GetValue(Consts.Producer_Config_AdminUrl);
                    ProducerTraceItems.Instance.ProducerConfigUrl = CmessagingAdminUrl;

                    var timeOutStr = CentralConfig.GetValue(Consts.Producer_Config_Timeout);
                    if(string.IsNullOrEmpty(timeOutStr))
                    {
                        Timeout = Consts.Producer_DefaultTimeout;
                    }
                    else
                    {
                        int time;
                        int.TryParse(timeOutStr, out time);
                        Timeout = time;
                    }

                    var connectionMaxCountStr = CentralConfig.GetValue(Consts.Producer_Config_ConnectionMaxCount);
                    if (string.IsNullOrEmpty(connectionMaxCountStr))
                    {
                        ConnectionMaxCount = Consts.Producer_ConnectionMaxCount;
                    }
                    else
                    {
                        int maxCount;
                        int.TryParse(connectionMaxCountStr, out maxCount);
                        ConnectionMaxCount = maxCount;
                    }
                    var connectionCountStr = CentralConfig.GetValue(Consts.Producer_Config_ConnectionCount);
                    if (string.IsNullOrEmpty(connectionCountStr))
                    {
                        connectionCount = -1;
                    }
                    else
                    {
                        int count;
                        int.TryParse(connectionCountStr, out count);
                        ConnectionCount = count;
                    }
                }
                catch (Exception ex)
                {
                    isSuccess = 0;
                    Logg.Write(ex, LogLevel.Error, "cmessaging.producer.configutil.runscheduler");
                }
                finally
                {
                    MetricManagerFactory.MetricManager.Set(new SyncCountMetric { Type = "metadata",IsSuccess = isSuccess.ToString()});
                }
            }, "ConfigScheduler", 60 * 1000, true);
        }
开发者ID:sdgdsffdsfff,项目名称:hermes.net,代码行数:66,代码来源:ConfigUtil.cs


注:本文中的IScheduler.Register方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。