Skip to content

Instantly share code, notes, and snippets.

@rpgmaker
Created September 10, 2012 19:33
Show Gist options
  • Save rpgmaker/3693258 to your computer and use it in GitHub Desktop.
Save rpgmaker/3693258 to your computer and use it in GitHub Desktop.
Setup Silverlight/WindowsPhone
private static void SetupExitEvent() {
#if WINDOWS_PHONE
Application.Current.Exit += (s, e) => Disconnect();
var phone = Application.Current.RootVisual as Microsoft.Phone.Controls.PhoneApplicationFrame;
if (phone != null) phone.BackKeyPress += (s, arg) => Disconnect();
#else
if (Application.Current.IsRunningOutOfBrowser)
Application.Current.Exit += (s, e) => Disconnect();
else {
HtmlPage.Window.Eval(String.Format(ScriptConstants.InitDurableFlag, Durable.ToString().ToLower()));
HtmlPage.Window.Eval(ScriptConstants.InvokeUrl);
HtmlPage.Window.Eval(String.Format(ScriptConstants.BeforeUnload,
Endpoint, ThrowException, ApiKey, PassCode, UserName));
Application.Current.Exit += (s, e) => Cleanup();
}
#endif
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment