Checking/Triggering when the File Write is complete

Easy Save 2 has been replaced by Easy Save 3, so is no longer supported.
Locked
JeremyFournier
Posts: 3
Joined: Thu Apr 27, 2017 8:15 pm

Checking/Triggering when the File Write is complete

Post 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.
User avatar
Joel
Moodkie Staff
Posts: 4846
Joined: Wed Nov 07, 2012 10:32 pm

Re: Checking/Triggering when the File Write is complete

Post 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
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
JeremyFournier
Posts: 3
Joined: Thu Apr 27, 2017 8:15 pm

Re: Checking/Triggering when the File Write is complete

Post by JeremyFournier »

Thanks for the quick response. I must have missed that function.
I'll give it a try today.
Locked