示例#1
0
        private void EnableOnThread(EnablingEventArgs e, Action actionOnComplete)
        {
            // TODO: There was a problem with enabled connections deserializing, failing
            // to enable, but still appearing enabled.
            // Setting this to false here seems to have fixed it, but I believe it is a
            // race condition that is happening.
            //IsEnabled = false;

            if (!Event.IsEnabled)
            {
                // Enable the event
                Event.Enable(e);
            }

            // If the event is not enabled we don't try to enable the reaction
            if (Event.IsEnabled && !Reaction.IsEnabled)
            {
                Reaction.Enable(e);

                if (!Reaction.IsEnabled)
                {
                    // If we got here, then it means the event is enabled and the reaction won't enable.
                    // We need to disable the event and then return out
                    Event.Disable(new DisabledEventArgs(e.WasConfiguring));
                }
            }

            // Double check that both are enabled. We shouldn't be able to get here if they aren't.
            IsEnabled = Event.IsEnabled && Reaction.IsEnabled;
            if (actionOnComplete != null)
            {
                actionOnComplete();
            }
        }
示例#2
0
        /// <summary>
        /// Enable this connection's event and reaction
        /// </summary>
        internal void Enable(EnablingEventArgs e, Action actionOnComplete)
        {
            // if we are already enabled, just stop
            if (IsEnabled)
            {
                if (actionOnComplete != null)
                {
                    actionOnComplete();
                }

                return;
            }

            EnableHelper(e, actionOnComplete);
        }
示例#3
0
 internal void Enable(EnablingEventArgs e)
 {
     try
     {
         OnEnabling(e);
         if (!e.Cancel)
         {
             IsEnabled = true;
         }
     }
     catch
     {
         ErrorLog.AddError(ErrorType.Failure, "Error enabling " + Name);
     }
 }
示例#4
0
 private void EnableHelper(EnablingEventArgs e, Action actionOnComplete)
 {
     ThreadPool.QueueUserWorkItem(o => EnableOnThread(e, actionOnComplete));
 }
示例#5
0
 /// <summary>
 /// This method is called before enabling the module. The module should verify that it can
 /// be started up. If for whatever reason it cannot, then e.Cancel should be set to true.
 /// The property WasConfiguring is set to true in the case that we are re-enabling after
 /// the configuration window was closed.
 /// This method is called on a background thread.
 /// </summary>
 /// <param name="e">Enabling arguments object</param>
 protected virtual void OnEnabling(EnablingEventArgs e)
 {
 }