Click here to Skip to main content
15,884,679 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi

I been scouring the web for a good way to implement an alarm in my application. My aim is to set a time of day and when it is reached, display a message to a user.

I was thinking of using a background worker that would Sleep until the required time and fire things on but I've seen various articles saying that Thread.Sleep() is not a good idea.

I didn't want to use a Timer in a class somewhere as it didn't seem very elegant and thought it could interfere with the application too much being on the same thread.

There didn't seem to be any lightweight solutions even though people were saying not to use Thread.Sleep(). Could Thread.Sleep() be ok in this situation as all it has to do is wait till the desired time to do something?

Any suggestions / ideas would be great.

Cheers

FoZ
Posted

1 solution

1)alarm-clock-application-in-net[^]

Check this thread.though u mentioned that you don't like to use timer, but then also have a look and more over they have some other solutions also..check them once.

2)Alarm Clock in C#[^]

here you can download the sample clock and check as they made the snooze function nicely.

Hope my links will be helpful to you
 
Share this answer
 
Comments
midnight_ 24-Jul-13 8:27am    
For me the discussion of a "elegant","decent" or "lightweight" solution for time-triggered alerts is a waste of time. Timer or a looped sleep-function is the best pratice to do that. The drift-effect is BS! If there exist a (big) time drift, the whole world trade system, goods traffic etc. would be inconsistent!
TheFoZ 24-Jul-13 8:42am    
Thanks Code-Hunt. I shall check those out this afternoon and get back to you what I have implemented.
[no name] 24-Jul-13 8:44am    
sure...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900