how to schedule a task in MVC4 C#?

前端 未结 7 1353
借酒劲吻你
借酒劲吻你 2020-12-09 16:22

I wanna create a notification system on my website?(something like stack-overflow)
How can we schedule a task for mailing the notification for users on each 24 hours?

7条回答
  •  执笔经年
    2020-12-09 17:21

    I use scheduled task of windows.

    I have build a little app than enter a record in the bd, then access the website with this recordId(Guid) as a parameter.

    In mvc i check if the id exist, if it exist i run tasks then delete the record in the db, if not i ignore it.

    this way im able to add schedule with a param. without updating the app each time i need a new scheduled task. i just add a new task like "myapp.exe /MyNewTaskName"

    hope this help someone ;-)

提交回复
热议问题