Search code examples
c#windows-servicesdelay

How to programmatically create pause in Windows Service app?


I am creating a Windows Service app that I would like to have programmatically pause when either a system error, odbc connection, or missing file error occur while . I was wondering if anyone knows how to do this? The Windows service app uses an odbc connection and datareader to connect to an MS Access database and an Oracle table, so there are the probable errors that I would be handling with those, I just want to allow a pause for the user handle the errors if/when they occur.


Solution

  • Have you tried?

    System.Threading.Thread.Sleep(1000); // sleep for 1 second
    

    Adjust the 1000 to 1000 times however long you want it to sleep in seconds.