New Posts New Posts RSS Feed: Grab when the browser shuts down
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Grab when the browser shuts down

 Post Reply Post Reply
Author
tj62 View Drop Down
Groupie
Groupie
Avatar

Joined: 21-May-2009
Location: Iceland
Posts: 81
Post Options Post Options   Quote tj62 Quote  Post ReplyReply Direct Link To This Post Topic: Grab when the browser shuts down
    Posted: 08-Nov-2010 at 7:57am

Is it possible in the Silverlight Client code to somehow grab when the user closes the hosting browser (or browser page)?

I need this to do some cleenup work like saving to the database display states, etc.
I also wnat to do a logout to free  resources on the server side that otherwise times out, if I have understood things right.
Back to Top
sbelini View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 13-Aug-2010
Location: Oakland
Posts: 786
Post Options Post Options   Quote sbelini Quote  Post ReplyReply Direct Link To This Post Posted: 09-Nov-2010 at 12:14pm
Hi tj62,
 
You can use the Application Exit event (in the App.xaml.cs file).
 
Regards,
   sbelini.
Back to Top
tj62 View Drop Down
Groupie
Groupie
Avatar

Joined: 21-May-2009
Location: Iceland
Posts: 81
Post Options Post Options   Quote tj62 Quote  Post ReplyReply Direct Link To This Post Posted: 10-Nov-2010 at 9:16am
Thank you sbelini,
Just one question. The logout is performed asynchronously, so as I'm closing the applicatoin I do not have any means of waiting for the logout callback to be called.  Is it possible to somehow force the application to wait for the callback .... or is it secured that the LogoutAsync() will go through to the server before the application shuts down?
 
The below call "persistenceGateway.Logout(null)" will call
  p_manager.LogoutAsync(null,null);
 

private void Application_Exit( object sender , EventArgs e )

{

    var persistenceGateway = m_bootstrapper.Container.Resolve<IPersistenceGateway>();

    if(persistenceGateway.p_isLoggedIn)

        persistenceGateway.Logout(null); // I set callback to null, as I do not know how to wait for it

}

Back to Top
sbelini View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 13-Aug-2010
Location: Oakland
Posts: 786
Post Options Post Options   Quote sbelini Quote  Post ReplyReply Direct Link To This Post Posted: 10-Nov-2010 at 3:34pm

tj62,

I've looked around and it seems it's not possible.
 
 
An Exit event handler should not include long-running, re-entrant, or cyclic code, ...
 
Regards,
   Silvio.


Edited by sbelini - 10-Nov-2010 at 4:14pm
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down