Of course, there are better ways to implement timed tasks, such as
Way One:
ASP. Mvc+quartz.net +corn +webapi,asp.net MVC to do task management platform, use Crontrigger to do timing trigger, quartz.net do timing execution control, WEBAPI implement execution logic
Way two:
A cliché, Windows service (boot) + timer (timer,quartz.net, etc.) +webapi (or other implementation logic)
Recently in doing Cs,timer implementation time control is not accurate, decided to implement the Windows plan, first introduce the Mshta bar:
Mshta
It supports command line parameters and can receive JS and VBS methods.
Examples are as follows:
// JS, to start with VBScript: implementation does not open the browser display Hello world! Mshta vbscript:window.execScript ("alert (' Hello world! ');", "JavaScript") (window.close)// VBA, to start with javascript: implementation does not open the form display Hello world!
WebApi
Create a WEBAPI, assuming the path is http://localhost:22673/api/SendMail/SendToLeader, need support HttpGet
Then, when rebuilding the Windows execution plan, in the action-select startup program, you can refer to the following:
// cmd command, you can implement logical control by executing the following statement without opening the browser // using Mshta directly as a program file can // creating a BAT file as a program file can also be mshta vbscript:createobject ("Wscript.Shell"). Run ("" "" IExplore "" http://localhost:22673/ Api/sendmail/sendtoleader ", 0) (Window.close)
WEBAPI + Windows Plan + Mshta implement scheduled Tasks