Skip to main content
Home Forums Silverlight Programming WCF RIA Services RIA call on Application Exit?
2 replies. Latest Post by jbloomer on July 9, 2009.
(1)
jbloomer
Member
42 points
61 Posts
07-08-2009 12:01 PM |
I want to make an RIA call when the silverlight application is exiting. I'm handling the App.Current.Exit event and making the call. But because the call is async the application exits before the call completes.
Has anyone found a good way around this?
I've also tried registering a javascript method OnBeforeUnload, but get the same result.
WilcoB
720 points
137 Posts
07-08-2009 4:34 PM |
There's little you can do. (Fortunately, from a user's point of view. Websites that just won't close can be really annoying.) The best option you probably have is to ask the user if they really want to leave the page. You can warn them that there is unsaved data. You do this by handling window.onunload (to do this from Silverlight, use the HTML bridge) and returning false.
Alternative/additionally, you can store data in isolated storage. Since that's synchronous, you're pretty much guaranteed that will work. The next time the user comes back, you can send the data to the server if that's the right thing to do.
07-09-2009 6:24 AM |
Ok, thanks. Looks like I'll have to show a message box to try and discourage the closing before saving.