locked
writing to disk in background RRS feed

  • Question

  • User-1665794747 posted

    My app needs to write data to disk on a regular basis (say every 5 minutes). I currently try to do this with a System.timers.timer that is started in the Application_Start event of the Global.asax, but it doesn't seem to work all the time. Is there a better way using a long-running background worker process that does [thread sleep/do the write] in a loop? If so, is the .net BackgroundWorker class OK or should I use a different class?

    Sunday, October 29, 2017 10:21 AM

All replies

  • User1120430333 posted

    My app needs to write data to disk on a regular basis (say every 5 minutes). I currently try to do this with a System.timers.timer that is started in the Application_Start event of the Global.asax, but it doesn't seem to work all the time. Is there a better way using a long-running background worker process that does [thread sleep/do the write] in a loop? If so, is the .net BackgroundWorker class OK or should I use a different class?

    A Web application is stateless, so the Web server knows nothing about the Web application (everything is lost) on the round trip between the browser and the Web server. It's not like a Windows form solution that is stateful, always running during the life of the program, where a background worker process can be hosted by the Windows form process.

    I mean the best you can do in keep time by using a variable in the Application cache and compare it to the current time to see if the 5 minutes has elapsed.

    Friday, November 3, 2017 3:24 PM