public void exec(Queue<DTEPrepared> commands, bool abortOnFirstError) { if(queue.level < 1 && commands.Count < 1) { return; } lock(_eLock) { if(queue.level == 0) { Log.Debug("DTE: init the queue"); queue.cmd = commands; Settings._.IgnoreActions = true; } if(queue.cmd.Count < 1) { Log.Debug("DTE recursion: all pushed :: level {0}", queue.level); return; } ++queue.level; DTEPrepared current = queue.cmd.Dequeue(); string progressCaption = String.Format("({0}/{1})", queue.level, queue.level + queue.cmd.Count); Exception terminated = null; try { // also error if command not available at current time // * +causes recursion with Debug.Start, Debug.StartWithoutDebugging, etc., Log.Info("DTE exec {0}: '{1}' [{2}]", progressCaption, current.name, current.args); exec(current.name, current.args); Log.Debug("DTE exec {0}: done.", progressCaption); } catch(Exception ex) { Log.Debug("DTE fail {0}: {1} :: '{2}'", progressCaption, ex.Message, current.name); terminated = ex; } if(queue.cmd.Count > 0) { // remaining commands if(terminated != null && abortOnFirstError) { Log.Info("DTE exec {0}: Aborted", progressCaption); } else { Log.Debug("DTE {0}: step into", progressCaption); exec((Queue<DTEPrepared>)null, abortOnFirstError); } } --queue.level; if(queue.level < 1) { Log.Debug("DTE: all completed"); Settings._.IgnoreActions = false; if(terminated != null) { throw new ExternalException(terminated.Message, terminated); } } } }
public void exec(DTEPrepared command) { exec(command.name, command.args); }