I want to create a web api which will accept one parameters like SocialSecurityNumber and it will check a database if it exists then it will push record into a new table if it did not exists in that table then it will pop it out from that table and this service need to be run everything like a cron job with no specific time , What is the best way to achieve this using .NET MVC.
Loading

Amit MohantyRank #112 · 20K reputationPosted Sep 27, 2023, 7:32 AM EDT
Hey Mark Tabor,
Could you clarify at which point you encountered the problem?
Mark TaborRank #914 · 2.3K reputationPosted Oct 4, 2023, 6:23 AM EDT
I did not encountered with any problem I would like to know how I could achieve that type of cron job like it continuesly runs and push and pop record like do I need to create a web service or windows service etc.
Sachin SinghRank #66 · 26.2K reputationPosted Oct 4, 2023, 6:29 AM EDT
You can use Hangfire or Quartz for the same.
Sam HobbsRank #107 · 20.5K reputationPosted Oct 4, 2023, 1:36 PM EDT
Are you trying to create a service like the ones shown in the Services tab of the Task Manager?
Create A Windows Service In C#
https://www.c-sharpcorner.com/article/create-windows-services-in-c-sharp
Create Windows Service using BackgroundService - .NET | Microsoft Learnhttps://learn.microsoft.com/en-us/dotnet/core/extensions/windows-service?pivots=dotnet-7-0
Amit MohantyRank #112 · 20K reputationPosted Oct 5, 2023, 1:30 AM EDT
You can use a library like Hangfire. Hangfire allows you to schedule background jobs in .NET applications.
Sam HobbsRank #107 · 20.5K reputationPosted Oct 5, 2023, 2:59 PM EDT
A cron job is not something that runs continuously. Cron is a scheduler, like the Windows Task Scheduler, that runs jobs as specified. I assume that Cron is a service that runs continuously but the jobs that it shedules are not normally (probably never) run continuously. In both Unix/Linux and in Windows services are what run continuously.
If you want someting like cron in Linux but for Windows then you can use the Windows Task Scheduler.