6

I have a c# function for producing thumbnail images, these images are displayed on web-page i.e ASP.net So how would i programtically call this back-end function let say everyday at 16:00 or at 3:00.

safi
  • 3,636
  • 8
  • 24
  • 37

3 Answers3

12

Write your code as a standalone console application - and then set up a scheduled task on the server to run your application at this time everyday.

If you want the task to run more than once a day you will have to set up a scheduled task for each time.

To set a scheduled task up go to Control Panel > Scheduled Tasks and then click on "Add Scheduled Task". This opens a wizard which guides you through the process:

  1. Select your application
  2. Give the task a name and select the frequency - you'll want Daily.
  3. Assign the time and whether you want this task every day, on weekdays or every days. Also when you want the task to start.
  4. Enter the credentials of the user account to run the application under. It would be best to set up a separate account for this.

Then you are done.

You can tweak the settings once it's set up.

ChrisF
  • 134,786
  • 31
  • 255
  • 325
  • can you forward any tutorial or link? so i can follow it step by step, specially sheduled task on the server? – safi Mar 20 '11 at 15:06
  • 3
    If you are going the scheduled task route, just code it as a normal console application. Not special tutorial need. Write it, compile it to an exe and use Windows to schedule the task to run every day at the time you want. – Tundey Mar 20 '11 at 15:09
  • Is it possible to do something similar in backend code? or what is the best way to run a function automatially everyday of an application which is host in a server? – huMpty duMpty Dec 21 '11 at 14:29
  • @huMptyduMpty - you can do the same on a server as you can on a client. The task scheduler is basically the same across Windows versions. – ChrisF Dec 21 '11 at 14:55
2

Either write a windows service or schedule a job.

Pradeep
  • 3,258
  • 1
  • 23
  • 36
  • can you forward any tutorial or link? so i can follow it step by step, specially sheduled task on the server – safi Mar 20 '11 at 15:07
  • @safi - I have already provided the links. Dive in and see how it works out for you. – Pradeep Mar 20 '11 at 15:11
1

Another way to handle it is by using Quartz.NET. It's pretty powerful job-scheduling library. This answer talks about using it with asp.net.

Community
  • 1
  • 1
James Sulak
  • 31,389
  • 11
  • 53
  • 57