コード例 #1
0
        /// <summary>
        /// Event handler for when the asynchronous find network sessions
        /// operation has completed.
        /// </summary>
        void FindSessionsOperationCompleted(object sender,
                                            OperationCompletedEventArgs e)
        {
            GameScreen nextScreen;

            try
            {
                // End the asynchronous find network sessions operation.
                AvailableNetworkSessionCollection availableSessions =
                    NetworkSession.EndFind(e.AsyncResult);

                if (availableSessions.Count == 0)
                {
                    // If we didn't find any sessions, display an error.
                    availableSessions.Dispose();

                    nextScreen = new MessageBoxScreen(Resources.NoSessionsFound, false);
                }
                else
                {
                    // If we did find some sessions, proceed to the JoinSessionScreen.
                    nextScreen = new JoinSessionScreen(availableSessions);
                }
            }
            catch (Exception exception)
            {
                nextScreen = new NetworkErrorScreen(exception);
            }

            ScreenManager.AddScreen(nextScreen, ControllingPlayer);
        }
コード例 #2
0
        /// <summary>
        /// Event handler for when the asynchronous find network sessions
        /// operation has completed.
        /// </summary>
        void FindSessionsOperationCompleted(object sender,
                                            OperationCompletedEventArgs e)
        {
            GameScreen nextScreen;

            try
            {
                // End the asynchronous find network sessions operation.
                AvailableNetworkSessionCollection availableSessions =
                                                NetworkSession.EndFind(e.AsyncResult);

                if (availableSessions.Count == 0)
                {
                    // If we didn't find any sessions, display an error.
                    availableSessions.Dispose();

                    nextScreen = new MessageBoxScreen(Resources.NoSessionsFound, false);
                }
                else
                {
                    // If we did find some sessions, proceed to the JoinSessionScreen.
                    nextScreen = new JoinSessionScreen(availableSessions);
                }
            }
            catch (Exception exception)
            {
                nextScreen = new NetworkErrorScreen(exception);
            }

            ScreenManager.AddScreen(nextScreen, ControllingPlayer);
        }