Exemplo n.º 1
0
            /// <summary>
            /// The one entry point, this is where requests should be sent
            /// </summary>
            public void TryPushRequest(IWebRequestObject requestObj, IResultHandler resultHandler)
            {
                // first, lock the queue
                RequestUpdateHandle.WaitOne( );

                // now we can be sure that it won't be pulled out and processed while we're trying to attach a handler.
                IWebRequestObject currObj = RequestQueue.Where(r => r.GetRequestUrl( ) == requestObj.GetRequestUrl( )).SingleOrDefault( );

                if (currObj != null)
                {
                    Rock.Mobile.Util.Debug.WriteLine(string.Format("{0} already requested. Not queueing.", currObj.GetRequestUrl( )));
                    currObj.AttachResultHandler(resultHandler);
                }
                else
                {
                    RequestQueue.Enqueue(requestObj);

                    Rock.Mobile.Util.Debug.WriteLine("Setting Wait Handle");
                    QueueProcessHandle.Set( );
                }

                // notify the thread it's ok to pull out more queue objects
                RequestUpdateHandle.Set( );
            }