Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

ASP.NET Forum


You are currently viewing our ASP.NET Forum as a guest. Please register to participate.
Login



Reply
Do An Action In Specific Date and Time
Old 11-17-2010, 02:45 AM Do An Action In Specific Date and Time
jenni1420's Avatar
Junior Talker

Posts: 3
Name: Pariya
Trades: 0
Hi all
I wanna do something like timing with ASP.net(c#).
for example I specify a date for sending an email (or any other jobs).
How can I do this? I don't have any idea.

any suggestion can help me.

thanks in advance.
jenni1420 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 11-19-2010, 06:18 AM Re: Do An Action In Specific Date and Time
Banned

Posts: 408
Name: mushget
Trades: 0
I got these code from web

Code:
 
<html>
<head>
    <title>Scheduling - Method 1</title>
</head>
<body>
<p>
    This script will print out &quot;Do Something!&quot; at the
    first request and then at the first request after midnight
    every day.
</p>
<%
' The way it stands, the "Do Something" line will run the first
' time it's hit after the web server starts and then again every
' day at the first hit after midnight.  If no one hits it for a
' day it won't run until hit.  This can be troublesome when
' you're doing a calculation which expects a day to have elapsed.

' Along the same lines, to make it not run upon starting,
' uncomment this section:
'If Application("LastScheduledRun") = 0 Then
'    ' Set the "LastScheduledRun" variable to something to
'    ' satisfy the condition checked below.  I'm setting it
'    ' to the current time, hence making the computer think
'    ' it just got done running it so there's no need to do
'    ' so again.
'    Application.Lock
'    Application("LastScheduledRun") = Now()
'    Application.UnLock
'End If

' Useful Debugging Lines:
'Response.Write Application("LastScheduledRun") & "<br />" & vbCrLf
'Response.Write Now() & "<br />" & vbCrLf
'Response.Write DateDiff("d", Application("LastScheduledRun"), Now()) _
'    & "<br />" & vbCrLf

' DateDiff works a little differently than you might expect.  If
' you ask for the difference in days, it does not check to see
' how many days worth of time have elapsed between two dates,
' but simply takes the dates and subtracts them.  Hence... from
' Jan 1, 2002, 11:59PM to Jan 2, 2002, 12:01AM returns 1 day even
' though in reality it's only been a couple seconds.  This makes
' it ideal for triggering stuff at midnight like we're doing here.
'
' If days between "LastScheduledRun" and the current time is > 0,
' this must be the first hit after midnight so we run our daily
' routine.  This condition is the key to what type of schedule is
' kept.  It can be changed to hourly, every 10 minutes, or even
' the first hit after 5pm... whatever you want, but it won't ever
' run unless someone has hit the page containing it.
If DateDiff("d", Application("LastScheduledRun"), Now()) > 0 Then
    ' This is where you put the commands you want to run on the
    ' schedule set up by the above condition.
    Response.Write "Do Something!"
        
    ' Reset our "LastScheduledRun" variable to the current date
    ' and time indicating we just did it.
    Application.Lock
    Application("LastScheduledRun") = Now()
    Application.UnLock
End If
%>
</body>
</html>
mushget is offline
Reply With Quote
View Public Profile Visit mushget's homepage!
 
Reply     « Reply to Do An Action In Specific Date and Time
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.12062 seconds with 12 queries