C2dmSharp.Server.C2dmMessageTransportAsync.requestStreamCallback C# (CSharp) Method

requestStreamCallback() static private method

static private requestStreamCallback ( IAsyncResult result ) : void
result IAsyncResult
return void
        static void requestStreamCallback(IAsyncResult result)
        {
            var msg = new C2dmMessage();

            try
            {
                var asyncParam = result.AsyncState as C2dmAsyncParameters;
                msg = asyncParam.Message;

                if (asyncParam != null)
                {
                    var wrStream = asyncParam.WebRequest.EndGetRequestStream(result);

                    using (var webReqStream = new StreamWriter(wrStream))
                    {
                        var data = asyncParam.Message.GetPostData();
                        webReqStream.Write(data);
                        webReqStream.Close();
                    }

                    try
                    {
                        asyncParam.WebRequest.BeginGetResponse(new AsyncCallback(responseCallback), asyncParam);
                    }
                    catch (WebException wex)
                    {
                        asyncParam.WebResponse = wex.Response as HttpWebResponse;
                        processResponseError(asyncParam);
                    }
                }
            }
            catch (Exception ex)
            {
                if (UnhandledException != null)
                    UnhandledException(msg, ex);
                else
                    throw ex;
            }
        }