Page 1 of 1

Checking/Triggering when the File Write is complete

Posted: Thu Apr 27, 2017 8:29 pm
by JeremyFournier
I've created a separate thread to Save my game (Save files can get VERY large sometimes and writing can take a while).

The Save itself seems to go pretty quickly now, but when it writes to the file it can take a lot longer. Is there a flag or event in place to determine when ES2 has finished writing? I can't find anything for it, but I'd like to have a display in the UI to warn players to not close the game until it's complete.

Re: Checking/Triggering when the File Write is complete

Posted: Fri Apr 28, 2017 7:35 am
by Joel
Hi there,

Because Easy Save stores data synchronously, as soon as the method returns it has finished writing. If you require more control, you can use an ES2Writer instead of ES2.Save so you can determine when in the process the data is written to file (i.e. using the Save() method).
bool isWritingData = false;

using(ES2Writer writer = ES2Writer.Create("myFile.txt"))
{
    writer.Write(data, "tag");
    isWritingData = true;
    writer.Save();
    isWritingData = false;
}
All the best,
Joel

Re: Checking/Triggering when the File Write is complete

Posted: Fri Apr 28, 2017 1:44 pm
by JeremyFournier
Thanks for the quick response. I must have missed that function.
I'll give it a try today.