Beispiel #1
0
 protected void FireConfigChange(ConfigChangeEventArgs changeEvent)
 {
     if (ConfigChanged != null)
     {
         foreach (ConfigChangeEvent handler in ConfigChanged.GetInvocationList())
         {
             m_executorService.QueueWorkItem((handlerCopy, changeEventCopy) =>
             {
                 string methodName;
                 if (handlerCopy.Target == null)
                 {
                     methodName = handlerCopy.Method.Name;
                 }
                 else
                 {
                     methodName = string.Format("{0}.{1}", handlerCopy.Target.GetType(), handlerCopy.Method.Name);
                 }
                 try
                 {
                     handlerCopy(this, changeEventCopy);
                 }
                 catch (Exception ex)
                 {
                     logger.Error(string.Format("Failed to invoke config change handler {0}", methodName), ex);
                 }
             }, handler, changeEvent);
         }
     }
 }
 protected void FireConfigChange(ConfigChangeEventArgs changeEvent)
 {
     if (ConfigChanged != null)
     {
         foreach (ConfigChangeEvent handler in ConfigChanged.GetInvocationList())
         {
             Task.Factory.StartNew(x =>
             {
                 var h = (ConfigChangeEvent)x;
                 string methodName;
                 if (h.Target == null)
                 {
                     methodName = h.GetType().Name;
                 }
                 else
                 {
                     methodName = $"{h.Target.GetType()}.{h.GetType().Name}";
                 }
                 try
                 {
                     h(this, changeEvent);
                 }
                 catch (Exception ex)
                 {
                     logger.Error(ex, $"Failed to invoke config change handler {methodName}");
                 }
             }, handler);
         }
     }
 }
        protected void FireConfigChange(ConfigChangeEventArgs changeEventCopy)
        {
            if (ConfigChanged != null)
            {
                foreach (var @delegate in ConfigChanged.GetInvocationList())
                {
                    var handlerCopy = (ConfigChangeEvent)@delegate;
                    ExecutorService.StartNew(() =>
                    {
                        string methodName;
                        if (handlerCopy.Target == null)
                        {
                            methodName = handlerCopy.Method.Name;
                        }
                        else
                        {
                            methodName = $"{handlerCopy.Target.GetType()}.{handlerCopy.Method.Name}";
                        }

                        try
                        {
                            handlerCopy(this, changeEventCopy);
                        }
                        catch (Exception ex)
                        {
                            Logger.Error($"Failed to invoke config change handler {methodName}", ex);
                        }
                    });
                }
            }
        }
Beispiel #4
0
 protected void FireConfigChange(ConfigChangeEventArgs changeEvent)
 {
     if (ConfigChanged != null)
     {
         foreach (ConfigChangeEvent handler in ConfigChanged.GetInvocationList())
         {
             //加入线程池执行
             ThreadPool.QueueUserWorkItem(state => handler.Invoke(this, changeEvent));
         }
     }
 }
 public void Dispose()
 {
     _configQueue?.Dispose();
     TokenSource?.Dispose();
     if (ConfigChanged == null)
     {
         return;
     }
     foreach (var subscriber in ConfigChanged.GetInvocationList())
     {
         ConfigChanged -= (BucketConfigHandler)subscriber;
     }
 }