tags:

views:

87

answers:

3

(I am not talking about Hibernate or NHibernate ORM )

Windows OS (and some linux version) have 'Hibernate' option to save the state and shutdown the Machine. And Later when we restart we can resume from previous stored state.

Is there any way to Hibernate an application alone ? I mean i want to close the application by saving its state and later when i start the application, it should resume from the previous stored state.

Is there any third party tools available, Or Can i add the feature to my application by using third party libraries ?

Edit: I have a .Net WinForm application with tabbed interface and more than 50 input controls . I need a solution to shutdown the application , and restart later with same values on textboxes. I can write a routine to store and restore all textbox values. But i am looking for some generic method, which can work for any application.

A: 

Objects containing memory that you own are not too difficult. The problem comes with resources owned by the OS (windows, threads, semaphores etc). You could write something that saved/restored the state of these OS-owned resource but you still need to destroy/recreate them.

What are your goals for doing this?

Andrew Grant
+1  A: 

You could bundle your application with its OS as an "appliance" and use something like VMWare to hibernate the whole virtual machine.

Or you could use Smalltalk.

(Both approaches are not something you can easily plug into an existing application, but hey, what you are asking for does seem to call for "platform-level support").

Thilo
A: 

There isn't a framework for this. The simplist way to achieve this, as you suggested, is to store your data in serializable objects and serialize them out into a file and then serialize them back in later.

That's not difficult, and gets you most of the way. It's also fairly generic-- you only need to write a few lines to serialize any amount of serializeable data in and out.

For more complex things, state like where the cursor was previously etc, should be pushed into a serializable object when the user attempts to close the app and manually pushed back when they load the app.

... but chances are your users aren't going to care about stuff like that, they probably just care that there data is back to how it was.

SCdF