Ok my app compiles info from server logs and adds the info to a database which is a long boring process and takes ages due to the number and size of the logs in question. So, I started worrying about what a pain in the arse it would be if the PC crashed or the app hung in the middle of compiling. Its easy enough to keep track of what logfile was last being compiled but not how much of the info was added to the DB.
So I opened a streamwriter at the start of the subroutine with an aim to create a recovery file. All it does is record the reverse of every entry into the DB on a separate line. So if recovery is need each of those lines (being SQL statements) are executed and the partial info removed from the DB then the user can start again from the last logfile being compiled. It is replaced each time the routine starts to compile a new logfile.
Now just when I was sitting back thinking I was really clever I tried it out only to find that because I dont close the streamwriter until the end of the for... next loop it doesnt actually write anything to the file if its stopped before then.
I know I can get around this by opening and closing the streamwriter everytime I want to add a line but that would add a silly amount of code due to the number of entries into the DB and its a slow enough process already.
Is there a less bulky way of overcoming this or am I gonna have to settle for adding lots more code?
So I opened a streamwriter at the start of the subroutine with an aim to create a recovery file. All it does is record the reverse of every entry into the DB on a separate line. So if recovery is need each of those lines (being SQL statements) are executed and the partial info removed from the DB then the user can start again from the last logfile being compiled. It is replaced each time the routine starts to compile a new logfile.
Now just when I was sitting back thinking I was really clever I tried it out only to find that because I dont close the streamwriter until the end of the for... next loop it doesnt actually write anything to the file if its stopped before then.
I know I can get around this by opening and closing the streamwriter everytime I want to add a line but that would add a silly amount of code due to the number of entries into the DB and its a slow enough process already.
Is there a less bulky way of overcoming this or am I gonna have to settle for adding lots more code?