void Application_Start(object sender, EventArgs e) { // Code qui s’exécute au démarrage de l’application AreaRegistration.RegisterAllAreas(); GlobalConfiguration.Configure(WebApiConfig.Register); RouteConfig.RegisterRoutes(RouteTable.Routes); ServerTimer timer = new ServerTimer(TimeSpan.FromSeconds(15), true); timer.BeginTimer(); timer.StopTask(); Application["ServerTimer"] = timer; }
public ActionResult TimerControl() { _APPTIMER = (ServerTimer)(HttpContext.ApplicationInstance).Application["ServerTimer"]; if (_APPTIMER.IsRunning) { _APPTIMER.StopTask(); } else { _APPTIMER.StartTask(); } return(View("DashBoard", "~/Views/Shared/_AdminLayout.cshtml", null)); }