title: Timers in Services
body: <p>we have recently added a new feature to our software - preview generation for documents that are uploaded and stored on the server. We did this the following way:</p>
  
  <ol>
  <li>The user uploads a document;</li>
  <li>Once the user opens the document information card, the preview for the recently uploaded document is issued (the info regarding the preview generation is stored in a db table);</li>
  <li>Every 30 seconds our service starts, reviews the preview table and initiates the preview generation procedures.</li>
  </ol>
  
  <p>The problem that I am facing now is this - the new code for generating previews uses some of our legacy code and it sometimes "freezes" the Word or Excel processes. The generation of preview stops and all the following previews stay in "pending" mode until I kill the Word, Excel processes (we test the preview for MS Office documents). After I kill the processes, preview generation continues on.</p>
  
  <p>I was thinking of implementing timers into our service so that if a service is awaiting for more that 1 minute after the preview generation has been started, it should kill the process  and continue on with generating previews for other documents.</p>
  
  <p>The main problem that I have is that i can not "move" the calls to our legacy code to separate processes as we have done with other documents (for example, we have implemented .ps file generation with GhostScript via Process'es).</p>
  
  <p>Any ideas on how to "processify" the calls to legacy code?</p>