Esempio n. 1
0
        private void RemoveProcess(ProcessBase process)
        {
            process.Succeeded -= HandleProcessSucceeded;
            process.Failed    -= HandleProcessFailed;
            process.Aborted   -= HandleProcessAborted;

            m_toRemove.Add(process.Id);
            Log.Trace("Flagged process {0} for removal", process.Name);

            if (process.Child == null)
            {
                return;
            }

            var activateChild = process.HasSucceeded ||
                                process.ActivateChildOnFailure ||
                                process.ActivateChildOnAbort;
            var child = process.RemoveChild();

            if (!activateChild)
            {
                Log.Debug("Children of {0} are not activating, aborting them",
                          process.Name);
                child.AbortAll();
                return;
            }

            if (!child.IsInitialized && !child.Initialize())
            {
                Log.Error("{0}, child of {1}, was not initialized and failed to " +
                          "initialize, aborting its chain", child.Name, process.Name);
                child.AbortAll();
                return;
            }

            child.Succeeded += HandleProcessSucceeded;
            child.Failed    += HandleProcessFailed;
            child.Aborted   += HandleProcessAborted;
            m_processes.Add(child);
            child.Resume();
        }