c# - how to run a background thread properly for a MVC app on shared host? -
i need run background thread mvc 4 app, thread wakes every hour or delete old files in database, goes sleep. method below: //delete old files database public void cleandb() { while (true) { using (userzipdbcontext db = new userzipdbcontext()) { //delete old files datetime timepoint = datetime.now.addhours(-24); foreach (userzip file in db.userfiles.where(f => f.uploadtime < timepoint)) { db.userfiles.remove(file); } db.savechanges(); } //sleep 1 hour thread.sleep(new timespan(1, 0, 0)); } } but should start thread? answer in this question creates new thread , start in global.asax , post mentions "asp.net not designed long running tasks". app run on shared host don't have admin privilege, don't think can install seperate program task. in short, is okay start thread in global.asax given thread doesn't (sleep ...