c# - Best way to repeat a process and continue even if it fails -


i have program restores databases. program reads file , restores 1 database @ time. program runs 1 time per database. need way repeat until databases restored. if database restore isn't successful, need process repeat until databases attempted restored. thinking of having program call program mentioned. this:

    public const string databaseattemptedrestore = "c:\\logs\\attempteddatabaserestore.log";     public const string databasestorestore = "c:\\logs\\databasestorestore.log";     static void main(string[] args)     {          //repeats restore, reading databasestorestore. needs called task scheduler         action torepeat = () =>         {             var proc = new process();            //database restore program             proc.startinfo.filename = @"c:\projects\dbrestoreprodconsole\bin\debug\dbrestoreprodconsole.exe";              // set output redirection              proc.startinfo.redirectstandardoutput = true;             proc.startinfo.redirectstandarderror = true;             proc.enableraisingevents = true;             proc.startinfo.createnowindow = true;              proc.startinfo.useshellexecute = false;             proc.startinfo.workingdirectory = @"c:\windows\syswow64";              // see below output handler              proc.start();             proc.waitforexit();         };         double linecount = file.readlines(databasestorestore).count();         double repeat = math.ceiling(linecount / 2);         enumerable.range(0, (int)repeat).tolist().foreach(i => torepeat());       } } 

}

i trying figure out best solution repeating process can track errors , run program smooth etc. program runs after hours doesn't need fast running program. databases restore per night around 8. 1 or 2 per night. suggestions appreciated. thank you.


Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

firemonkey - How do I make a beep sound in Android using Delphi and the API? -