Schedule task in ASP.NET

前端 未结 2 510
野性不改
野性不改 2020-12-07 04:43

I\'m trying to create a task scheduler that runs twice a day. I\'ve implemented a task scheduler using CacheItemRemovedCallaback, as suggested in this post and this blog. I

相关标签:
2条回答
  • 2020-12-07 05:20

    I found solutions that mention Windows services or Windows task scheduler

    That's what you should be using. A web application doesn't "always run." It responds to requests, that's all. Unless something is actively making a request to the website, it's not doing anything.

    but that doesn't work for me since I need to be able to let the admin configure the times through the web application

    Sure it does. More than one application can share a single database. In this case you'd have two applications:

    • A Web Application where users can login and maintain the data related to the scheduled tasks.
    • A Windows Service (or scheduled Console Application) which runs in the background on the server and executes the configured tasks which it reads from the database.
    0 讨论(0)
  • 2020-12-07 05:39

    Using hacks like Windows Scheduled Tasks and Control Panel abilities are not nice solutions. They sucks most of the time, they are a headache.

    You can use ATrigger scheduling service. A .Net library is also available to create scheduled tasks without overhead.

    //Tags: Tags are required to identify tasks. 
    //read more at: http://atrigger.com/docs/wiki/9/rest-api-v10-parameter-tag_
    Dictionary<string, string> tags = new Dictionary<string, string>();
    tags.Add("type", "test");
    
    //Create
    ATrigger.Client.doCreate(TimeQuantity.Hour(), "12", "http://www.example.com/myTask?something", tags);
    

    Disclaimer: I was among the ATrigger team. It's a freeware and I have not any commercial purpose.

    0 讨论(0)
提交回复
热议问题