Not the real question, but related: My app serializes it’s settings to isolated storage in main forms closing event. It works nice except some edge cases (Like 1% of shutdowns result in empty,broken file). Is this expected?
Now the real question:
What is the general pattern when dealing with serialization in C# or Java desktop apps? Should I wait for app’s exit? Use an timer and save do serialization at certain intervals?
You should save whenever the settings change, unless you have high volume.
The most important issue here is corrupted files. You should save to a temporary file and when the serialisation is complete you should then swap the files in a quick, atomic operation. If anything goes wrong you can read the old copy of the file.