2011-10-16 130 views

回答

1

我在我的設備上執行此操作。

只需添加一個Timer和一個簡短函數Reset()

const int TIME_LIMIT = 50000; // set to whatever you need 
int timeout; 
Timer Timer1; 

void Form1() { 
    Timer1 = new Timer(); 
    Timer1.Interval = 200; // 200 milliseconds 
    Timer1.Tick += new EventHandler(Timer_Tick); 
} 

void ShowSubPanel() { 
    Timer_Reset(); 
    panelSub1.BringToFront(); 
} 

void Timer_Reset() { 
    Timer_Stop(); 
    Timer_Start(); 
} 

void Timer_Start() { 
    timeout = 0; 
    Timer1.Start(); 
} 

void Timer_Stop() { 
    Timer1.Stop(); 
} 

void Timer_Tick() { 
    if (TIME_LIMIT < timeout++) { 
    Timer_Stop(); 
    // Here, call your Main Form 
    Main.BringToFront(); // I use Panels instead of forms 
    } 
} 
+1

就像一些信息,如果你有很多形式(我意識到你正在使用面板),這將有點乏味,這將是很難擴展/維護。 – ctacke

2

我同意Henk的意見,不清楚您是否想要檢測缺少用戶輸入或檢測是否存在這些接口。用於檢測用戶空閒狀況,this might be of interest。用於檢測硬件接口可用性,this might help