views:

45

answers:

2

Hi,

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 think thats not a good idea, is there a better way?

+1  A: 

Use System.Windows.Forms.Timer

nos
+3  A: 

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"

dbemerlin