开发者

silverlight exit call a Web service

I want to send data to the server when you close the application

public App()
        {
            this.Startup += this.App开发者_开发问答lication_Startup;
            this.Exit += this.Application_Exit;
            this.UnhandledException += this.Application_UnhandledException;
            InitializeComponent();
        }

private void Application_Exit(object sender, EventArgs e)
        {
           ClientReverse.UserExitGameAsync((Guid)Login);
        }

Server:

public void UserExitGame(Guid UserGuid)
        {
            Games.Games.ExitUserGames(UserGuid);
        }

but the server side is not satisfied.


It is already too late when you reach the ApplicationExit event.

I have seen Javascript that keeps on a webpage until confirmed (Stack Overflow does it a lot). You might want to modify a version of that Javascript that sends a message back to the Silverlight app before it allows page closing.

Calling Silverlight methods from JS is easy (you can simply expose SL methods to JS with the [Scriptable] attribute).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜