-1

I have created one class. I can manually execute that class from any controller and its work properly. But now i want to schedule this task automatically and without depending on controller. Is there any functionality in mvc 5 for trigger specific class at fixed time ?

Thank you in advance.

Camilo Terevinto
  • 31,141
  • 6
  • 88
  • 120
Dip Surani
  • 61
  • 6
  • 1
    There is no built-in triggering mechanism in asp.net for running code at a given time (a "job"). You need to build your own or use other software (CRON or Windows Scheduler). – gunr2171 Jul 09 '18 at 13:41
  • I think [this answer](https://stackoverflow.com/a/3243354/7147323) might help you. Cheers! – mb14 Jul 09 '18 at 13:43
  • i am building web application.Is there any alternative solution ? execute it without any external software. or something like ajax timer which help to run class automatically ? – Dip Surani Jul 09 '18 at 13:47
  • @mb14 that reference is very useful for desktop application. for MVC 5 web application is there any functionality same like Application Idle ? Because lines of code is written in simple c# class and separate from all controller. i just want to execute that class without involving any controller and automatically – Dip Surani Jul 09 '18 at 13:57
  • The only way I am aware of is what @gunr2171 mentioned. Using scheduled task or other CRON job – ivcubr Jul 09 '18 at 14:00
  • 1
    What you're asking asp.net to do is fundamentally different from what it's designed to do. asp.net is a client/server architecture. It is only going to run code when a client browser asks it to do something. Unless you modify the underlying engine, it doesn't run code in the background. – gunr2171 Jul 09 '18 at 14:02
  • thanks buddy u cleared my confusion @gunr2171 – Dip Surani Jul 09 '18 at 14:23

1 Answers1

0

in a ASP.NET web app, there are methods to "simulate" sending out scheduled events - check out this CodeProject article

and of course, you can also just simply "roll your own" in any .NET app - check out this CodeProject article for a sample implementation

Taken from the link provided in comments.

Community
  • 1
  • 1
mb14
  • 460
  • 4
  • 15