Exemplo n.º 1
0
            void ThreadProc( )
            {
                while (true)
                {
                    Rock.Mobile.Util.Debug.WriteLine("ThreadProc: Sleeping...");
                    QueueProcessHandle.WaitOne( );
                    Rock.Mobile.Util.Debug.WriteLine("ThreadProc: Waking for work");

                    // while there are requests pending, process them
                    while (RequestQueue.IsEmpty == false)
                    {
                        Rock.Mobile.Util.Debug.WriteLine("ThreadProc: Processing Request");

                        // get the web request out of the queue
                        RequestUpdateHandle.WaitOne( );          //Wait to make sure no other thread is using the Queue
                        IWebRequestObject requestObj = null;
                        RequestQueue.TryDequeue(out requestObj); //yank it out
                        RequestUpdateHandle.Set( );              // all clear

                        if (requestObj != null)
                        {
                            // execute it
                            requestObj.ProcessRequest( );
                        }
                    }
                }
            }