我在主函数中有一些代码,并且我想通过在随机时间(例如100毫秒)之后调用另一个函数foo
来中断主函数。我该如何做到这一点? 例如见下图:如何在C#中运行主函数一段时间后调用函数
void main()
{
intsruction 1;
intsruction 2;
intsruction 3;// for example if 100 ms ends after executing instruction
//3 the foo function should call after it, and after executing
//foo function, returns here and execute instruction 4
intsruction 4;
intsruction 5;
intsruction 6;
}
foo的功能:
void foo()
{
instruction 7;
}
执行完毕后,程序的流程可以是:
intsruction 1;
intsruction 2;
intsruction 3;
intsruction 7;// foo
intsruction 4;
intsruction 5;
intsruction 6;
请详细说明。中断意味着阻止?在foo内部等待100毫秒或启动foo之前? – EngineerSpock 2015-03-02 15:11:24
任何代码示例都可以帮助您更好地理解您的问题。 – 2015-03-02 15:11:36
请再次参阅编辑。感谢 – 2015-03-02 15:34:33