c# - Force my console application to Sleep/Pause/Hibernate -


i running non-threaded application responsible checking database file, updating location , moving file new directory.

however every monday-thursday-saturday our server containing sql server reboots @ 8:40 pm. @ 8:30 pm , until 9:00 pm or 8-9 if easier need program sleep.

on days @ 8pm (or 8:30 pm) program sleep/wait/pause until 9:00 pm (i can safely assume reboot finished time).

is easy/possible? can done without threading? if have use threading easy implement has never used threads?

james, try / catch , using not mutually exclusive.

if approach decide take retry on sqlexception should not, use:

thread.sleep(1800000); 

this wait 30 minutes. try call again. advise against this, quick, dirty option.

this might useful.

you should design application handle situation database connectivity lost. batch data intend write , send once connectivity reestablished.

consider rewriting service. perhaps want log connectivity issues.

try {     using (sqlconnection sqlconnection = new sqlconnection(connectionprovider.connectionstring(databasename)))     {         using (sqlcommand command = new sqlcommand())         {              if (sqlconnection.state != system.data.connectionstate.open)             {                 sqlconnection.open();             }             //command.configure etc...             command.executenonquery();          }     } } catch (sqlexception ex) {     //retry } 

Comments

Popular posts from this blog

c++ - CryptStringToBinary API behavior -

java.util.scanner - How to read and add only numbers to array from a text file -

iphone - Three second countdown in cocos2d -