Inheritance: IAsyncResult, IDisposable
Example #1
0
 /// <summary>
 /// Enqueues a callback method that should be invoked on the
 /// main thread by the UnityMainThreadDispatcher.
 /// </summary>
 /// <param name="asyncResult">Instance of RuntimeAsyncResult that contains
 /// all the information about the callback.</param>
 public void EnqueueCallback(RuntimeAsyncResult asyncResult)
 {
     lock (_callbacksLock)
     {
         _callbacks.Enqueue(asyncResult);
     }
 }
Example #2
0
        /// <summary>
        /// Dequeues an callback from the queue of pending callbacks that
        /// need to be invoked.
        /// </summary>
        /// <returns></returns>
        public RuntimeAsyncResult DequeueCallback()
        {
            RuntimeAsyncResult asyncResult = null;

            lock (_callbacksLock)
            {
                if (_callbacks.Count > 0)
                {
                    asyncResult = _callbacks.Dequeue();
                }
            }
            return(asyncResult);
        }
Example #3
0
        private void ProcessRequests()
        {
            IUnityHttpRequest unityHttpRequest = UnityRequestQueue.Instance.DequeueRequest();

            if (unityHttpRequest != null)
            {
                this.StartCoroutine(InvokeRequest(unityHttpRequest));
            }
            RuntimeAsyncResult runtimeAsyncResult = UnityRequestQueue.Instance.DequeueCallback();

            if (runtimeAsyncResult != null && runtimeAsyncResult.Action != null)
            {
                try
                {
                    runtimeAsyncResult.Action(runtimeAsyncResult.Request, runtimeAsyncResult.Response, runtimeAsyncResult.Exception, runtimeAsyncResult.AsyncOptions);
                }
                catch (Exception exception)
                {
                    _logger.Error(exception, "An unhandled exception was thrown from the callback method {0}.", runtimeAsyncResult.Request.ToString());
                }
            }
            Action action = UnityRequestQueue.Instance.DequeueMainThreadOperation();

            if (action != null)
            {
                try
                {
                    action();
                }
                catch (Exception exception2)
                {
                    _logger.Error(exception2, "An unhandled exception was thrown from the callback method");
                }
            }
            NetworkReachability networkReachability = ServiceFactory.Instance.GetService <INetworkReachability>() as NetworkReachability;

            if (_currentNetworkStatus != networkReachability.NetworkStatus)
            {
                _currentNetworkStatus = networkReachability.NetworkStatus;
                networkReachability.OnNetworkReachabilityChanged(_currentNetworkStatus);
            }
        }
Example #4
0
 /// <summary>
 /// Enqueues a callback method that should be invoked on the
 /// main thread by the UnityMainThreadDispatcher.
 /// </summary>
 /// <param name="asyncResult">Instance of RuntimeAsyncResult that contains
 /// all the information about the callback.</param>
 public void EnqueueCallback(RuntimeAsyncResult asyncResult)
 {
     lock (_callbacksLock)
     {
         _callbacks.Enqueue(asyncResult);
     }
 }