Application Ending : Save the static object in a File to reload it alter !

S

Shanli RICHEZ

I'm using ASP.NET and quite a lot of object in memory instead of a database.

The question is that I tried to save the data, serialize them in a XML file
to save them when the application is ending.

event : Application_End in Global.asax.

But the object are not accesible from there so I can't save them.

Any idea ???

Thanks.
 
P

Paul Glavich [MVP - ASP.NET]

Why dont you save the information to the database on first created and when
it changes (ie. pro-actively) rather than trying to save it when the
application ends. That way, the database always contains a reflection of
what is held in memory and reloading it from where you left off is trivial
 
S

Shanli RICHEZ

The static object contains counter, statistique per user that can be
increment/decrement 15,000 times an hour.

That's why I do not save them in the database because it will take to much
ressource.

I could save them every minute with a timer, but the problem is that when I
shut down the machine I lose the lastest information. So I wanted to catch
the event n application end to save them.

Shanli
 
P

Paul Glavich [MVP - ASP.NET]

Then what about the finaliser for the object? It will only be garbage
collected when the apDomain is being unloaded and it keeps that logic within
the object itself.
 
S

Shanli RICHEZ

That's seems to be a good idea.

Thanks.


Paul Glavich said:
Then what about the finaliser for the object? It will only be garbage
collected when the apDomain is being unloaded and it keeps that logic within
the object itself.

--
- Paul Glavich
Microsoft MVP - ASP.NET


when
 
S

Scott Allen

What happens in Application_End that prevents the save from working?

I'd shy away from the finalizer because there is no guarantee the
finalizer will run. There is one thread dedicated to running
finalizers and the runtime can timeout an operation on the thread to
prevent the thread from hanging.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top