Click here to Skip to main content
15,881,413 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,


I want to execute some function on specific time.(e.g. Every night 12.00). So, how can I do this??
Posted
Updated 22-Jul-12 21:22pm
v3
Comments
Sergey Alexandrovich Kryukov 23-Jul-12 2:37am    
Call a function of an application which runs non-stop, or execute an application?
--SA

As from your question tag I assume you want to do this in ASP.Net.

First of all understand that ASP.Net is based on request - response[^] model. There are few ways to implement scheduling(Execute some code at specified time) in ASP.Net code.

1. Create and start timer instance in Global.asax Application_Start event. On each timer tick event do what you want to do.
I do not recommend this way, as it is bad idea to write timer functionality in ASP.Net.

2. Write scheduling windows service to call a web service.
i. Write the code that you want to execute on specified time in a web service.
ii. Write a windows service to call this web service at specified time.
You can use Quartz.net[^] for this purpose.
I recommend this strategy

3. If you are hosting your website in shared environment like on shared hosting space, then you may use SQL Job schedule to execute a code periodically.
i. SQL Job Scheduler[^]
ii. http://msdn.microsoft.com/en-us/library/ms191439.aspx[^]

4. Else give a thought to Windows Task Scheduler
i. Windows Task Scheduler[^]
ii. http://msdn.microsoft.com/en-us/library/windows/desktop/aa383614(v=vs.85).aspx[^]

Hope this helps.
All the best.
 
Share this answer
 
v2
Comments
Ankur Ramanuj 23-Jul-12 4:46am    
Actually i have work on Payroll software and i want to call attendance process cs file at night(12.00)..so how can i do i don't understand...
Pravin Patil, Mumbai 23-Jul-12 5:28am    
What is attendance process file? Is it a web service or a web page or what?
Ankur Ramanuj 23-Jul-12 7:12am    
its a one class file..firstly i'll say i have create one web base application and in this i have create one attendance process class file.i want to call it every day at 12:00 am.
Pravin Patil, Mumbai 23-Jul-12 13:44pm    
You need to create one web service. Write Attendance Process class code in Webservice.
Then write a scheduling windows service(maybe you can use timer or threading to make it execute at 12.00 everyday. Call your web service from this windows service.
Ankur Ramanuj 25-Jul-12 1:40am    
how can i use timer or thread??
create web page along with your function and create task to execute this web page.
 
Share this answer
 
v2
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900