开发者

How to prevent GUI blocking?

I have a timer that ticks every 3 seconds. If the timer found something a messagebox will show. Then the timer should wait 30 seconds, before he show again the messagebox (the user of course must have time to react).

How can I handle this?

I tried a Thread.Sleep(30000), but the GUI blocks of course.

My other Idea is a second timer that will be activated after the first ticks and reactivate the first timer in the tick-method.

So: t1 tick -> msg box -> after click -> t2 enable (30 sec tick) -> t2 tick, enable t1

But I thin开发者_JS百科k thats not a good idea, is there a better way?


Depends on the Language.

In any case you have to create a second Thread that does the waiting and checking.

In case of .NET you might want to look into the "BackgroundWorker"


Use System.Windows.Forms.Timer

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜