Xml writer sometimes corrupts files on unexpected poweroff

hi all,

I implemented an imgui model and use a custom datatype inside a reactive channel to hold its configuration values (like @sebescudie doing in his gamma launcher). Sometimes the power to our machines get cut, and then (just sometimes) my settings.xml gets corrupted.

we also found some mentions on the web about similar issues with the dotnet XML writer class: https://www.reddit.com/r/dotnet/comments/jgaah7/xml_file_corrupted_during_hard_shutdown/

I checked my app, and it just writes to the file when I change settings. Probably once on startup, when the datatype is created - but how can this single write cause problems hours later at an unexpected shutdown?

image

any ideas?