Ejemplo n.º 1
0
        /// <summary>
        /// Query the server list. Task result will be true when finished
        /// </summary>
        /// <returns></returns>
        public async Task <bool> RunQueryAsync(float timeoutSeconds = 10)
        {
            var stopwatch = System.Diagnostics.Stopwatch.StartNew();

            Reset();
            LaunchQuery();

            var thisRequest = request;

            while (IsRefreshing)
            {
                await Task.Delay(33);

                //
                // The request has been cancelled or changed in some way
                //
                if (request == IntPtr.Zero || thisRequest.Value != request.Value)
                {
                    return(false);
                }

                var r = Responsive.Count;

                UpdatePending();
                UpdateResponsive();

                if (r != Responsive.Count)
                {
                    OnChanges?.Invoke();
                }

                if (stopwatch.Elapsed.TotalSeconds > timeoutSeconds)
                {
                    break;
                }
            }

            MovePendingToUnresponsive();
            OnChanges?.Invoke();

            return(true);
        }
Ejemplo n.º 2
0
 internal void InvokeChanges()
 {
     OnChanges?.Invoke();
 }
Ejemplo n.º 3
0
 public void Stop()
 {
     StopGame = true;
     OnChanges?.Invoke();
 }
Ejemplo n.º 4
0
 public void InvokeChanges()
 {
     OnChanges?.Invoke();
 }