public static HTTPRequestQueue Load()
        {
            IsolatedStorageFile storage = IsolatedStorageFile.GetUserStoreForApplication();
            HTTPRequestQueue    tmpQueue;

            if (storage.FileExists(AppSettingsFileName))
            {
                IsolatedStorageFileStream stream = null;
                try
                {
                    stream = storage.OpenFile(AppSettingsFileName, FileMode.Open);
                    XmlSerializer xml = new XmlSerializer(typeof(HTTPRequestQueue));

                    tmpQueue = xml.Deserialize(stream) as HTTPRequestQueue;
                }
                catch (Exception ex)
                {
                    tmpQueue = new HTTPRequestQueue();
                }
                finally
                {
                    if (stream != null)
                    {
                        stream.Close();
                        stream.Dispose();
                    }
                }
            }
            else
            {
                tmpQueue = new HTTPRequestQueue();
            }

            return(tmpQueue);
        }
        public static HTTPRequestQueue Load()
        {
            IsolatedStorageFile storage = IsolatedStorageFile.GetUserStoreForApplication();
            HTTPRequestQueue tmpQueue;

            if (storage.FileExists(AppSettingsFileName))
            {
                IsolatedStorageFileStream stream = null;
                try
                {
                    stream = storage.OpenFile(AppSettingsFileName, FileMode.Open);
                    XmlSerializer xml = new XmlSerializer(typeof(HTTPRequestQueue));

                    tmpQueue = xml.Deserialize(stream) as HTTPRequestQueue;
                }
                catch (Exception ex)
                {
                    tmpQueue = new HTTPRequestQueue();
                }
                finally
                {
                    if (stream != null)
                    {
                        stream.Close();
                        stream.Dispose();
                    }
                }
            }
            else
            {
                tmpQueue = new HTTPRequestQueue();
            }

            return tmpQueue;
        }
        void FinishWebRequest(IAsyncResult result)
        {
            HTTPRequestQueue ptr = (HTTPRequestQueue)result.AsyncState;

            if (currentStatus == QueueStatus.Stopped)
            {
                ptr.WebRequest = null; //Queue is been stopped
                return;
            }

            HttpWebRequest   request        = (HttpWebRequest)ptr.WebRequest;
            HttpWebResponse  response       = null;
            Stream           streamResponse = null;
            StreamReader     streamRead     = null;
            WebRequestStatus status         = WebRequestStatus.Completed;

            bool requestSuccess = true;

            try
            {
                // End the operation
                response       = (HttpWebResponse)request.EndGetResponse(result);
                streamResponse = response.GetResponseStream();
                streamRead     = new StreamReader(streamResponse);
                string responseString = streamRead.ReadToEnd();
                RequestCompleted(currentRequest, responseString); //Request completed succesfully
            }
            catch (WebException e)
            {
                requestSuccess = false;
                status         = WebRequestStatus.WebException;
            }
            catch (Exception ex)
            {
                requestSuccess = false;
                status         = WebRequestStatus.FinishWebRequestGeneralError;
            }
            finally
            {
                // Close stream objects
                if (streamResponse != null)
                {
                    streamResponse.Close();
                }
                if (streamRead != null)
                {
                    streamRead.Close();
                }
                if (response != null)
                {
                    response.Close();
                }

                ptr.WebRequest = null;

                if (requestSuccess)
                {
                    MakeNextRequest();
                }
                else
                {
                    if (currentRequest.Callback != null)
                    {
                        currentRequest.Callback(new WebRequestCompletedArgs(status));
                    }
                }
            }
        }