Running Code every 10 Minutes

I want to execute a piece of code every ten minutes or so.  How can I do that in VB.NET 1.1?  The code will send an E-mail to roughly 100 people.  I don't need assistance on the E-mailing, just the piece that manages the timing.  If it helps, as an example, let's say I have 500 people to send a message to.  I need to send the message to the first 100, wait 10 minutes, then send it to 101-200, wait ten minutes, and so on until I have sent it to all 100.  I need to be able to set this code to start at a particular time as well.
ftbadolatoAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

GHCS_MarkCommented:
Use a Timer object and set the interval to 600 seconds or 60000 milliseconds.  I can not remember which it is based upon.

If you want to start it at a specific time, you could simply use the same routine to see if the current time is beyond an "Alarm" time and then run the code.  You may need two timer objects though.
0
Mike TomlinsonMiddle School Assistant TeacherCommented:
The Timer Interval is in Milliseconds.

So you can do:  (in the Form Load event)

    Timer1.Interval = TimeSpan.FromMinutes(10).TotalMilliseconds
0
ftbadolatoAuthor Commented:
Sorry...this is really new to me.  Can you provide an entire snippet of how to set the start time and then make it run every ten minutes....or maybe I should just make it run every ten minutes all the time.  Any objections to that?
0
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

Mike TomlinsonMiddle School Assistant TeacherCommented:
Is this WinForms or WebForms?
0
ftbadolatoAuthor Commented:
web
0
Mike TomlinsonMiddle School Assistant TeacherCommented:
Ah...sorry then.  I have nooooooooooooo clue how to do it properly in a webform.  =\

I'm a WinForms guy...  ;)
0
GHCS_MarkCommented:
About the only way I can see you doing this would be to utilise a javascript which implements setTimeout()
0
Bruce_1975Commented:
If it's running on the server, you can use the following example

Regards,
Bruce
Public Class TimerExample
    Dim WithEvents timer As System.Timers.Timer
 
    Public Sub New(ByVal Interval As Integer)
        timer = New System.Timers.Timer(TimeSpan.FromMinutes(Interval).TotalMilliseconds)
        timer.AutoReset = True
        timer.Start()
    End Sub
 
    Private Sub timer_Elapsed(ByVal sender As Object, ByVal e As System.Timers.ElapsedEventArgs) Handles timer.Elapsed
        'do the mailing stuff here
    End Sub
 
End Class

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Jorge PaulinoIT Pro/DeveloperCommented:
Why don't you do that using AJAX ?

How Do I: Use the ASP.NET AJAX Timer Control?
http://www.asp.net/learn/ajax-videos/video-99.aspx
0
ftbadolatoAuthor Commented:
I don't get it....points have been awarded....why delete it?
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.