我在主函數中有一些代碼,並且我想通過在隨機時間(例如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