2011-10-16 77 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