Solved

Running Code every 10 Minutes

Posted on 2008-06-25
11
1,999 Views
Last Modified: 2010-05-18
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.
0
Comment
Question by:ftbadolato
  • 3
  • 3
  • 2
  • +2
11 Comments
 
LVL 3

Expert Comment

by:GHCS_Mark
ID: 21870732
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
 
LVL 85

Assisted Solution

by:Mike Tomlinson
Mike Tomlinson earned 25 total points
ID: 21870946
The Timer Interval is in Milliseconds.

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

    Timer1.Interval = TimeSpan.FromMinutes(10).TotalMilliseconds
0
 

Author Comment

by:ftbadolato
ID: 21871222
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
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 21871339
Is this WinForms or WebForms?
0
 

Author Comment

by:ftbadolato
ID: 21871666
web
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 21871702
Ah...sorry then.  I have nooooooooooooo clue how to do it properly in a webform.  =\

I'm a WinForms guy...  ;)
0
 
LVL 3

Expert Comment

by:GHCS_Mark
ID: 21872653
About the only way I can see you doing this would be to utilise a javascript which implements setTimeout()
0
 
LVL 6

Accepted Solution

by:
Bruce_1975 earned 80 total points
ID: 21873514
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
 
LVL 48

Assisted Solution

by:jpaulino
jpaulino earned 20 total points
ID: 21879688
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
 

Author Comment

by:ftbadolato
ID: 23114584
I don't get it....points have been awarded....why delete it?
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
SLMGR Switches Are Not Working On KMS Host 3 67
How do ASP.NET and MVC work together? 4 25
fso.FolderExists("\\server\HiddenFolder$") 4 49
Connection String 16 43
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
I designed this idea while studying technology in the classroom.  This is a semester long project.  Students are asked to take photographs on a specific topic which they find meaningful, it can be a place or situation such as travel or homelessness.…
A company’s greatest vulnerability is their email. CEO fraud, ransomware and spear phishing attacks are the no1 threat to a company’s security. Cybercrime is responsible for the largest loss of money to companies today with losses projected to r…

914 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now