I'm running into a weird problem and I want to know if it is normal or if I'm missing something.
Here's the situation :
Game.OnExiting()
method to call my Web Service, and I have put a breakpoint on this lineIs it normal that the call is not processed on the server because the game is exiting?
Here's the code :
protected override void OnExiting(object sender, EventArgs args)
{
if (GameManager.Instance.IsOnlineGame && !Guide.IsVisible)
{
GameManager.Instance.Multiplayer.QuitGame();
}
base.OnExiting(sender, args);
}
internal void QuitGame()
{
_client.QuitGameAsync(GameManager.Instance.GameId, _myRank);
}
Scientific explanations:
HttpWebRequests are dispatched from the UI thread so if your app/game UI thread never updates after your call to quit the game the request will never be sent. You can test this by creating a web request and then looping until the request is completed (waiting on the async result complete state) - the request will never be sent and you will wait forever. You could try introducing a delay of a few hundred milliseconds (without putting the UI thread to sleep which would still block the request) and see if the request is made. In XNA this would mean doing nothing for a few update calls to see if the request is sent. You could also use a timer.
Credits : dadoo Games on http://forums.create.msdn.com/forums/t/79737.aspx