ASP
Long running processes
Several ways, often not reliable (the first 2 run in IIS and could be easily recycled...)
- Thread it. You can use a hashtable to signal results ("LongProcess" can be an instance method of the Page, accessing controls). Full example
ThreadStart ts = new ThreadStart(LongProcess);
Thread workerThread = new Thread(ts);
workerThread.Start(); - Use a web service with the attributes [WebMethod] [SoapDocumentMethod(OneWay=true)]
- A windows service, if you can persuade people to deploy one.
- IIS Application Initialization Module.
-
- It's a separate download in IIS 7/7.5, and an optional "windows feature" that must be turned on in IIS 8 (IIS. WWW Services, Application Development Features, Application Initialization.
- In IIS7, edit ApplicationHost.config (see post above).
- In IIS8,
- on AppPool, Start Automatically=true and Start Mode= AlwaysRunning
- On Application, Advanced Settings, Preload Enabled = true
- If the AppDomain restarts, in Application_End, do a WebClient ping to restart it.
- The job is just a static member on Global.asax which is created in Application_Start. If you implement IRegisterdObject.Stop, you can HostingEnvironment.RegisterObject(job);
-
- Hangfire is a Sql-Server backed solution.
- In .net 4.5.2 (May 2013), there is HostingEnvironment.QueueBackgroundWorkItem(cancellationToken => { /* code */ });
- In Azure, there are WebJobs