示例#1
0
 internal void Disable(DisabledEventArgs e)
 {
     try
     {
         OnDisabled(e);
         IsEnabled = false;
     }
     catch
     {
         ErrorLog.AddError(ErrorType.Failure, "Error disabling " + Name);
     }
 }
示例#2
0
        internal void Disable(DisabledEventArgs e, Action actionOnComplete)
        {
            // if we aren't already enabled, just stop
            if (!IsEnabled)
            {
                if (actionOnComplete != null)
                {
                    actionOnComplete();
                }

                return;
            }

            ThreadPool.QueueUserWorkItem(o => DisableOnThread(e, actionOnComplete));
        }
示例#3
0
        private void DisableOnThread(DisabledEventArgs e, Action actionOnComplete)
        {
            if (Event.IsEnabled)
            {
                try
                {
                    Event.Disable(e);
                }
                catch
                {
                    ErrorLog.AddError(ErrorType.Failure, "Error disabling " + Event.Name);
                }
            }

            if (Reaction.IsEnabled)
            {
                try
                {
                    Reaction.Disable(e);
                }
                catch
                {
                    ErrorLog.AddError(ErrorType.Failure, "Error enabling " + Reaction.Name);
                }
            }

            /* This might need to be changed to be more like
             * Enable() if we decide that modules can
             * decide not to shut down. That doesn't
             * seem like a reasonable option though, so for
             * now, this will stay as it is
             */
            IsEnabled = false;
            if (actionOnComplete != null)
            {
                actionOnComplete();
            }
        }
示例#4
0
 /// <summary>
 /// This method is called when the module is disabled; on application shutdown, on
 /// connection deleted, and when the configuration for the module is opened. In the case
 /// that it is called when configuration is opened, e.IsConfiguring will be set to true.
 /// This method is called on a background thread.
 /// </summary>
 /// <param name="e">Disabled event arguments</param>
 protected virtual void OnDisabled(DisabledEventArgs e)
 {
 }