Skip to main content

Microsoft Silverlight

Answered Question RIA call on Application Exit?RSS Feed

(1)

jbloomer
jbloomer

Member

Member

42 points

61 Posts

RIA call on Application Exit?

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
WilcoB

Member

Member

720 points

137 Posts

Answered Question

Re: RIA call on Application Exit?

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.

- Wilco Bauwer (MSFT) / http://www.wilcob.com

jbloomer
jbloomer

Member

Member

42 points

61 Posts

Re: Re: RIA call on Application Exit?

Ok, thanks. Looks like I'll have to show a message box to try and discourage the closing before saving.

  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities