RunTestRoutine() is called from main via a button click.
public async Task RunTestRoutine() // <----- taken out
{
Abort = new CancellationTokenSource();
int reached = await RunTestConfigReached(Abort.Token);
if(reached == 0)
{
// Yay it completed.
}
else if(reached > 0)
{
// Boo it didn't.
OnFailed(this, new FailedPositionEventArgs(Model.TestState, String.Format("Step {0} in test configuration failed",reached)));
}
}
private async void StartTestStartTest_Click(object sender, RoutedEventArgs e)// <---- Called directly from main
{
if (AdamCont == null)
{ return; }
Abort = new CancellationTokenSource();
int reached = await AdamCont.RunTestConfigReached(Abort.Token);
if (reached == 0)
{
LightControl(SignalLight.GreenLight);
Model.TestState = TestCycleState.NotInTest;
}
else if (reached > 0)
{
LightControl(SignalLight.RedLight);
Model.TestState = TestCycleState.NotInTest;
// OnFailed(this, new FailedPositionEventArgs(Model.TestState, String.Format("Step {0} in test configuration failed", reached)));
//Now failedPosition can be called directly.
FailedPosition( new FailedPositionEventArgs(Model.TestState, String.Format("Step {0} in test configuration failed", reached)));
}
else
{
LightControl(SignalLight.AmberLight);
Model.TestState = TestCycleState.NotInTest;
}
}