Wrox Programmer Forums
|
Visual Basic 2005 Basics If you are new to Visual Basic programming with version 2005, this is the place to start your questions. For questions about the book: Beginning Visual Basic 2005 by Thearon Willis and Bryan Newsome, ISBN: 0-7645-7401-9 please, use this forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual Basic 2005 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 27th, 2008, 09:16 AM
Registered User
 
Join Date: Mar 2008
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default Timed alerts.

Hi, I have created a simple exe that runs in the system tray and pops up a balloon notification every 30mins. It works fine, but i have used the Timer function, which every 30mins it pops up the alert and i click it and it goes away. What i need is for it to be in sync with the system clock, so that it only alerts me on the half hour and hour of every hour, or to when i specify. E.g. the alert pops up at 07:00, 07:30, 08:00 .. etc.

Is this possible?

Thanks,
Julian

 
Old June 27th, 2008, 10:31 AM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

Sure.

Check out Sleep for threads.

Have your app sleep for some amount of time (1 second? 100 mS? resolution is your choice). When it wakes up, have it check what time it is. Process the anwer to that, and if it is the ½ hour or straight-up time, take your action. Otherwise, re-invoke sleeping. If your resolution is 500mS or 1 second, you probably will have to ignore the 1's colum of the seconds in your check. If the resolution is finer than that, you probably won't. (Of course, there is the chance that your app won't get serviced the instant it wakes up, depending on how busy the computer is, who has priority, and so on.)
 
Old June 27th, 2008, 01:36 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Perhaps a better approach would be to compute delays. When the app starts, figure out what the next alert time will be and calculate a sleep period. Then the app will remain dormant until the actual time it needs to do something. You'll eliminate the "polling" behavior. If you have a screen used for changing the alert times, then you simply recalculate the alert sleep based on all possible alerts so it will pick up new alerts that are set for times earlier than the one it's currently waiting on.

-Peter
compiledthoughts.com
 
Old June 27th, 2008, 03:46 PM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

well... if you’re going to go and be all systematic about it...
 
Old June 28th, 2008, 09:26 AM
Registered User
 
Join Date: Mar 2008
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks guys, will take a look and see how i get on :)






Similar Threads
Thread Thread Starter Forum Replies Last Post
catch the alerts catchrohith Classic ASP Basics 1 October 26th, 2006 06:39 AM
Closing Pages and popup alerts Quick209 ASP.NET 2.0 Basics 0 November 14th, 2005 09:26 PM
Formatting Alerts fs22 Javascript How-To 3 June 9th, 2004 04:15 PM
Alerts rwalker ASP.NET 1.0 and 1.1 Basics 8 March 8th, 2004 09:04 AM
Using Alerts rwalker ASP.NET 1.0 and 1.1 Basics 2 March 3rd, 2004 11:00 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.