Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Compact Framework / January 2006

Tip: Looking for answers? Try searching our database.

Alarm Event

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Tamer Hesham - 19 Jan 2006 14:31 GMT
Hi All,
I have a program that must check system time every 1 minute, Is there a way
to do this without using the Timer tick event, as in timer when i enabling
it, it may not at zero second, but i want the time checking be at zero second
(at the begining of the minute), so is there an eveny fired at a certain time
i can set ?
Thanks in advance
Regards

Tamer Hesham
Paul G. Tobey [eMVP] - 19 Jan 2006 15:46 GMT
How accurate does it have to be?  You might be able to use CeRunAppAtTime()
(search the archives), to do something like this, although once per minute
isn't really what it was designed for.  It's not going to be accurate enough
to say that it fired during the first second of each minute.

Why would you need to check the system time every minute?

Paul T.

> Hi All,
> I have a program that must check system time every 1 minute, Is there a
[quoted text clipped - 9 lines]
>
> Tamer Hesham
Tamer Hesham - 19 Jan 2006 23:43 GMT
It doesnt need to be at the first second of the minute, may be till 5 seconds
will be great..
I am making a program like an alarm, user set a time, when it comes the
program play sound, user set hour and min, so i want to fire the event at the
begining of the min, till 10 sec will be good..

Tamer Hesham
Lonifasiko - 20 Jan 2006 06:44 GMT
My application also works with alarms that user establishes, to
remember him activities to do, appointments..........
I'm using timers, they are "quite" precise and I'm afraid it's the only
way to achieve what you want.

On the other hand, my application synchronizes with a server using
Merge Repplication and my problem is that time of the PDA must be
always the same as server's, and it's not.
If you switch on/off the PDA, soft-reset and so on, time of the PDA
varies from time of the server and they are not always the same.
Therefore, an alarm that had been established from server side to fire
at 8:00 exactly, in a couple or days or week of PDA using, could fire
in the PDA at 8:01 or 8:02.
If tasks to do are not critical........timers are quite a good choice.

Regards.
Paul G. Tobey [eMVP] - 20 Jan 2006 16:45 GMT
It's not going to be guaranteed to be that close (or even nearly that
close).  If you look at the clock now, decide how long until the alarm is
supposed to fire, then do a WaitForSingleObject() on some event (typically
an event indicating that the main part of your code wants you to exit), with
a time-out set to the time before the alarm should fire, you should get
something pretty accurate.  That is:

// Get current time

// Subtract from alarm target time to figure out how many ms (yes,
milliseconds), until the alarm
// should fire.

// Wait for either a) the exit event to be set or b) for the time-out to
occur.
result = WaitForSingleObject( exitEvent, msTillAlarm );
if ( result == WAIT_TIMEOUT )
{
   // The time-out occurred, so do whatever you do to sound the alarm.
}
else
{
   // The main application set the exit event.  Presumably, we should
terminate this thread.
}

If you ever set alarms on your Pocket PC, you see that they seldom fire
exactly when requested, but they're close enough for most things (if you set
your alarm clock for 6am, you don't really care if it goes off at 6:00:00 or
6:00:59; at worst, you're 60 seconds late for work).  They use
CeRunAppAtTime().

Paul T.

> It doesnt need to be at the first second of the minute, may be till 5
> seconds
[quoted text clipped - 5 lines]
>
> Tamer Hesham

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.