/** * @param threadContext * @return * */ private IterationListener InitRun(NetMeterContext threadContext) { threadContext.SetVariables(threadVars); threadContext.SetThreadNum(getThreadNum()); threadContext.GetVariables().Add(LAST_SAMPLE_OK, TRUE); threadContext.SetThread(this); threadContext.SetThreadGroup(threadGroup); threadContext.SetEngine(engine); testTree.Traverse(compiler); // log.info("Thread started: " + Thread.currentThread().getName()); /* * Setting SamplingStarted before the contollers are initialised allows * them to access the running values of functions and variables (however * it does not seem to help with the listeners) */ if (startEarlier) { threadContext.SetSamplingStarted(true); } controller.Initialize(); IterationListener iterationListener = new IterationListener(); controller.addIterationListener(iterationListener); if (!startEarlier) { threadContext.SetSamplingStarted(true); } ThreadStarted(); return(iterationListener); }
/** * @param threadContext * @return * */ private IterationListener InitRun(NetMeterContext threadContext) { threadContext.SetVariables(threadVars); threadContext.SetThreadNum(getThreadNum()); threadContext.GetVariables().Add(LAST_SAMPLE_OK, TRUE); threadContext.SetThread(this); threadContext.SetThreadGroup(threadGroup); threadContext.SetEngine(engine); testTree.Traverse(compiler); // log.info("Thread started: " + Thread.currentThread().getName()); /* * Setting SamplingStarted before the contollers are initialised allows * them to access the running values of functions and variables (however * it does not seem to help with the listeners) */ if (startEarlier) { threadContext.SetSamplingStarted(true); } controller.Initialize(); IterationListener iterationListener = new IterationListener(); controller.addIterationListener(iterationListener); if (!startEarlier) { threadContext.SetSamplingStarted(true); } ThreadStarted(); return iterationListener; }
public IterationListener.Status update (IterationListener.UpdateMessage updateMessage) { if (InvokeRequired) { BeginInvoke(new MethodInvoker(() => update(updateMessage))); return (IterationListener.Status) IterationListener.Status.Ok; } if (_isClosing) return IterationListener.Status.Cancel; string[] parts = updateMessage.message.Split('*'); string taskName = parts.Length > 1 ? parts[0] : String.Empty; string message = parts.Length > 1 ? parts[1] : parts[0]; int index = updateMessage.iterationIndex; int count = updateMessage.iterationCount; // if the update is not row-specific, update the window title string[] parts2 = Text.Split(':'); if (String.IsNullOrEmpty(taskName)) { Text = String.Format("{0}: {1} ({2}/{3})", parts2[0], message, index, count); return IterationListener.Status.Ok; } else if (parts.Length > 1) Text = parts2[0]; var row = _rowByTaskName[taskName]; var progressCell = _progressCellByTaskName[taskName]; if (row.Index >= 2)//Environment.ProcessorCount) { JobDataView.Rows.Remove(row); JobDataView.Rows.Insert(0, row); } if (count == 0) { progressCell.ProgressBarStyle = ProgressBarStyle.Marquee; if (index == 0) { progressCell.Text = message; progressCell.Value = 0; } else { progressCell.Text = String.Format("{0} ({1})", message, index + 1); } } else { progressCell.ProgressBarStyle = ProgressBarStyle.Continuous; progressCell.Maximum = count; progressCell.Value = index + 1; progressCell.Text = String.Format("{0} ({1}/{2})", message, index + 1, count); } lock (_lastMessageByTaskName) if (!_lastMessageByTaskName.ContainsKey(taskName) || _lastMessageByTaskName[taskName] != message) { _lastMessageByTaskName[taskName] = message; _textBoxLogByTaskName[taskName].AppendText(String.Format("{0}{1}", message, Environment.NewLine)); } if (message.Contains("done")) if (TaskbarManager.IsPlatformSupported) { TaskbarManager.Instance.SetProgressState(TaskbarProgressBarState.Normal); TaskbarManager.Instance.SetProgressValue(++_tasksDone, _rowByTaskName.Count); } return IterationListener.Status.Ok; }