views:

95

answers:

1

Hi,

I am developing a mobile application, in C#, with the .NET Compact Framework 3.5. It needs to store the state in memory, i.e., if the application crashes, the application has to reboot into the state before the crash.

All business logic has to be stored too, as well as the forms. I would like to know if there is an easy way to manage such a feature, do you have any clues? Is serialization the right thing to do?

Thanks.

+1  A: 

At first you shouldn't store the state in RAM, since it is lost after a crash. Instead you must use a non-volatile memory like a storage crash. Writing to this kind of medium is slow, so you must act accordingly.

I have seen some devices that had a recovery application, which can be configured to duplicate the whole content of RAM into flash every some period of time. After a hard reset it could bring the whole device to where it was (at least just before the last time RAM was duplicated).

Perhaps this kind of thing is an overkill for you. It could be simpler, as you've said, to serialize all your objects and periodically copy them to flash. It will be your responsibility what gets duplicated and what's not. It will be also your responsibility to initialize the application at its previous state.

kgiannakakis