how Call Method in ASP.NET MVC For example, in one method, bring out a list of people who are born and send them a congratulatory message.
Asked
Active
Viewed 1,518 times
4
-
1Maybe "Windows Task Scheduler" can work for you? – Daniel Stackenland Jan 07 '20 at 07:47
1 Answers
4
There is no code provided but generally, there are several options I could think of:
- The built-in
BackgroundService
https://learn.microsoft.com/en-us/aspnet/core/fundamentals/host/hosted-services?view=aspnetcore-3.1&tabs=visual-studio
you can create a structure like this in the backgroundservice:
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
while (!stoppingToken.IsCancellationRequested)
{
//Do work
await Task.Delay(timeSpan, stoppingToken);
}
}
Quartz
task scheduler, which might be overkill for your task.
https://www.quartz-scheduler.net/A long-running timer (not recommended)
Windows Task Scheduler Task on the Server, triggering an API Method.
(Suggested by Fildor)

Siavash Rostami
- 1,883
- 4
- 17
- 31
-
14. Windows Task Scheduler Task on the Server, triggering an API Method. – Fildor Jan 07 '20 at 07:48
-
yea, but that barely falls under the asp.net service. the scheduling part kinda external to the service. – Siavash Rostami Jan 07 '20 at 07:49
-
So? All you do is trigger a logic. All the code is in the ASP.NET MVC Application. That way you can even change the scheduling without touching the App's code or having to restart or anything. – Fildor Jan 07 '20 at 07:50
-
sure. but when enlisting the options i was thinking of more convenient internal ways of doing so, is all :) – Siavash Rostami Jan 07 '20 at 07:53
-
1That granted. But having used Task Scheduler, to me, that's much more convenient than any of the above listed options (for the reasons in above comment). So feel free to add it to your answer, or don't. Your choice. – Fildor Jan 07 '20 at 07:55
-
1
-
I am using DNTScheduler .with nuget Install-Package DNTScheduler -Version 1.1.0 thank you. – A.R.SEIF Jan 07 '20 at 09:30