开发者

How to prevent GUI blocking?

开发者 https://www.devze.com 2022-12-22 14:19 出处:网络
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

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

精彩评论

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

关注公众号