I'm in the process of working out the architecture for a website and I've come across something I've never done before with ASP.NET. What I'd like to do is every night run a query against entities in a database table to check a date column and perform either X or Y action, depending on what the date is. Basically I want a function to be called once a night. Everything that I've searched for has lead me in a few different directions that seem either extremely complex for such a simple action, or are leaned more toward job queuing which isn't exactly what I want.
Any suggestions are welcome, just looking for the simplest approach. Thanks!
Regardless of the Windows version or edition you have, you can also use the Run window to launch the Task Scheduler. Press the Windows + R keys on your keyboard to open Run, and then type taskschd. msc in the Open field. Finally, click or tap on OK, or press Enter on your keyboard.
The ASP.NET MVC Scheduler, or event calendar, is a fully featured event calendar component that helps users manage their time efficiently. It facilitates easy resource scheduling and the rescheduling of events or appointments through editor pop-ups, drag and drop, and resizing actions.
I've used Hangfire on a project before for doing stuff like this. Its absolutely awesome and keeps all of your code in one solution (no messing around with windows services), I highly recommend.
I can think of three different options.
If the work you're doing is purely database related, most database platforms such as Microsoft SQL Server, Oracle, etc have the ability to schedule jobs that run at regular intervals. These jobs could be SQL statements or stored procedures. MS SQL Server would also let you call C# code from within a stored procedure, which would be handy.
Use the operating system to schedule. Windows has Windows Scheduler jobs (The AT
command) and Unix has cron jobs. You could schedule an executable to run every night, which would run C# code or SQL code.
Write your own scheduling service. This service would run all the time as a Windows Service, and execute some code at a regular interval. Check out scheduling frameworks such as Quartz.net, which can help organize some of the scheduling details.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With