NextStep = 1;
while(ManualEventSet.WaitOne())
{
Process();
Thread.Sleep(20);
}
void Process()
{
switch(nextStep)
{
case 1:
DoSomething;
break; // 会一直执行这个Step
// 正常流程的下一步
nextStep = 2;
// 失败了可以跳到统一的错误处理
break;
case 2:
nextStep = 3;
break;
case 3:
break;
case 4:
break;
}
}