本文整理汇总了C#中IProgress.Reset方法的典型用法代码示例。如果您正苦于以下问题:C# IProgress.Reset方法的具体用法?C# IProgress.Reset怎么用?C# IProgress.Reset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IProgress
的用法示例。
在下文中一共展示了IProgress.Reset方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExecuteExperiment
/// <summary>
/// Executes the experiment.
/// </summary>
/// <param name="progress">The progress.</param>
public void ExecuteExperiment(IProgress progress)
{
try
{
bool successful = true;
string endMessage = Messages.ExperimentRunnerSuccessMessage;
OnExperimentStarted();
if (m_runnableExperiment.IsEmpty == false)
{
if (progress != null)
{
progress.Reset();
progress.NumSteps = m_runnableExperiment.Nodes.Count;
// Start at 1 so user can tell something is happening.
progress.Increment();
progress.CurrentStatus = Messages.ProgressExperimentProcessing;
}
// collection of nodes currently executing
ActiveNodesList currentActiveNodesList = new ActiveNodesList(m_runnableExperiment.TerminateExperimentExecutionResetEvent);
// collection of nodes pending to be started
Queue<RunnableNode> pendingNodesToBeRun = new Queue<RunnableNode>();
// enqueue start node
pendingNodesToBeRun.Enqueue(m_runnableExperiment.StartNode);
bool end = false;
while (!end) //until end component is not completed
{
//activate all pending nodes
while (pendingNodesToBeRun.Count > 0)
{
RunnableNode node = pendingNodesToBeRun.Dequeue();
if (currentActiveNodesList.Contains(node) == false)
{
RunnableNodeThreadArgs args = new RunnableNodeThreadArgs { ExperimentRunner = this };
var resetEvent = node.Run(args);
currentActiveNodesList.Add(node, resetEvent);
}
}
if (currentActiveNodesList.Count > 0)
{
//wait for any node to be completed
int index = WaitHandle.WaitAny(currentActiveNodesList.NodeResetEvents);
//the index 0 is the termination signal... if the index is higher than zero then process the completed node
if (index > 0)
{
RunnableNode completedNode = currentActiveNodesList.TakeOutNode(index);
if (progress != null)
{
progress.Increment();
}
// if experiment runner reaches end node, then prepare to exit the experiment runner
if (completedNode.Equals(m_runnableExperiment.EndNode))
{
end = true;
// if there are any other nodes still running other than end node
if (currentActiveNodesList.Count > 1)
{
successful = false;
endMessage = Messages.ExperimentRunnerErrorMessage;
TerminateExperimentExecution(); //send signal terminate in case sth else in sub level experiment is running
NLog.LogManager.GetCurrentClassLogger().Error(Messages.ExperimentRunnerEarlyTerminationErrorMessage);
}
}
else
{
// send one token to all successor nodes
foreach (RunnableNode successorNode in completedNode.NextNodes)
{
//sends token; method will return true if successor node is ready to be run
bool readyToRun = successorNode.SendToken();
if (readyToRun)
{
//add node to the pending nodes to be activated
pendingNodesToBeRun.Enqueue(successorNode);
}
}
}
}
else
{
//EXECUTED ON SIGNAL TERMINATED
// If any node signal TERMINATE for any reason, we shut down the experiment and stop processing new nodes.
end = true;
//.........这里部分代码省略.........