Possible Duplicate:
Is XMLDocument.Save an atomic operation?
I appear to have a Heisenbug in my program. I need to export an Xml file and then re-import it. The problem is that sometimes before the Xml file has finished saving the program will continue to the next line to try and re-import it and because it is not finished saving the application will crash. When I debug it there is enough time for the file to save so the program doesn't crash.
I could use Thread.Sleep
but on slower computers it might still crash if it took too long.
I'm using XmlDocument.Save
to save the file. I was wondering if there might be a way to implement a callback of some sort for when the file has been completely saved.