Preforming scheduled tasks in C# .NET MVC Application

后端 未结 4 778
礼貌的吻别
礼貌的吻别 2020-12-17 06:18

I\'m trying to implement a logic for my .NET MVC application where I would trigger scheduled tasks in my application on a following basis:

First scheduled ta         


        
相关标签:
4条回答
  • 2020-12-17 06:56

    I had similar problem with my ASP.NET MVC App, I Wanted to do some works in special times and finally I could find a way. My solution was Plesk scheduels task feature, as where the most windows servers use plesk control panel You can publish your app on a windows server with plesk CP and create a new actionresualt in your MVC App and write Your codes that want to execute them in special times. By plesk scheduels tasks create a new task and call your Url with a cron that You made it, You can make many crons. If I Could not explain It very well You can search about Plesk Schedueled Tasks on the Internet, You can find many good answers.

    0 讨论(0)
  • 2020-12-17 07:00

    You don't want to be performing long running and recurring background tasks in your web application for multiple reasons. You may go through the following blog post which outlines them very well.

    I would recommend you moving this logic into a separate Windows Service or even a Console Application whose runs could be scheduled with the Windows Task Scheduler at the desired intervals.

    The benefit of this is that you will be off-loading your web application from doing long running tasks which will be consuming precious resources from your webserver. Of course both the webserver and the worker service could share a common centralized datastore or messaging layer in order to communicate if necessary.

    0 讨论(0)
  • 2020-12-17 07:04

    For scheduling tasks in ASP.NET MVC you have several options:

    • 3rd party libraries like FluentScheduler, HangFire or Quartz.net.
    • Since .Net 4.5.2 there is QueueBackgroundWorkItem, a native way to schedule work in the background. Here is a guide on how to use it with ASP.NET MVC.
    • Azure services for background workloads and scheduled tasks. There are a couple of those aimed at different tasks, here is an overview of them.

    Be careful if you try to implement a custom solution yourself, as any exception in a thread not associated with a request would halt the entire process.

    0 讨论(0)
  • 2020-12-17 07:05

    Visual Cron is a decent task scheduler you can use. We use it, calling service methods on our asp.net / mvc / webapi servers.

    http://www.visualcron.com/

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