Beispiel #1
0
        public static AvailableNetworkSessionCollection EndFind(IAsyncResult result)
        {
            AvailableNetworkSessionCollection availableSessions = null;

            try
            {
                availableSessions = AsyncFindCaller.EndInvoke(result);
            }
            catch
            {
                throw;
            }
            finally
            {
                AsyncFindCaller = null;
            }
            return(availableSessions);
        }
Beispiel #2
0
        public static IAsyncResult BeginFind(NetworkSessionType sessionType, IEnumerable <SignedInGamer> localGamers, NetworkSessionProperties searchProperties, AsyncCallback callback, Object asyncState)
        {
            if (Session != null || AsyncCreateCaller != null || AsyncFindCaller != null || AsyncJoinCaller != null)
            {
                throw new InvalidOperationException("Only one NetworkSession allowed");
            }
            if (sessionType == NetworkSessionType.Local)
            {
                throw new ArgumentException("Find cannot be used with NetworkSessionType.Local");
            }
            if (localGamers == null)
            {
                throw new ArgumentNullException("localGamers");
            }
            foreach (var localGamer in localGamers)
            {
                if (localGamer == null)
                {
                    throw new ArgumentNullException("Element of localGamers");
                }
            }
            if (searchProperties == null)
            {
                searchProperties = new NetworkSessionProperties();
            }

            AsyncFindCaller = new AsyncFind(InternalFind);
            IAsyncResult result = null;

            try
            {
                result = AsyncFindCaller.BeginInvoke(sessionType, localGamers, searchProperties, callback, asyncState);
            }
            catch
            {
                AsyncFindCaller = null;
                throw;
            }
            return(result);
        }