日期:2014-05-19  浏览次数:20885 次

关于延时问题
for(int   a=0;a <phsAlarmCount;a++)
                        {
                                if   (phsAlarm[a].rmvCount   <   4)
                                {
                                        SendKeys.Send( "rmv-aiuen: "+phsAlarm[a].nr5essAll[1]);
                                        //此处加入2秒延时
                                        SendKeys.Send( "rst-aiuen: "+phsAlarm[a].nr5essAll[1]);

                                }
                        }
请问我如何在标记的地方加入2秒的延时,thread.sleep不好用,还有用   DateTime   a   =   DateTime.Now.Second;然后另外设个datetime   b,用b.second=a.second的循环也不好用,这2种方法都会造成程序假死,无法响应,有没有高手指点下该怎么处理啊

------解决方案--------------------
int t = System.Environment.TickCount;
while(System.Environment.TickCount - t < 2000) Application.DoEvents();