예제 #1
0
 /// <summary>
 /// 开始请求
 /// </summary>
 /// <param name="state"></param>
 private static void AsyncRequest(AsyncState state)
 {
     try
     {
         state.r.BeginGetRequestStream(new AsyncCallback(RequestCallBack), state);
     }
     catch
     {
         if (state.dele != null)
         {
             state.dele(null);
         }
     }
 }
예제 #2
0
 /// <summary>
 /// 开始请求响应
 /// </summary>
 /// <param name="state"></param>
 private static void AsyncResponse(AsyncState state)
 {
     try
     {
         state.r.BeginGetResponse(new AsyncCallback(ResponseCallBack), state);
     }
     catch
     {
         if (state.dele != null)
         {
             state.dele(null);
         }
     }
 }
예제 #3
0
        /// <summary>
        /// Web请求异步回调函数
        /// </summary>
        /// <param name="r"></param>
        private static void RequestCallBack(IAsyncResult r)
        {
            AsyncState state = r.AsyncState as AsyncState;

            try
            {
                Stream s = state.r.EndGetRequestStream(r);
                s.Write(state.data, 0, state.data.Length);
                s.Close();
                AsyncResponse(state);
            }
            catch
            {
                if (state.dele != null)
                {
                    state.dele(null);
                }
            }
        }
예제 #4
0
        /// <summary>
        /// Web响应异步回调函数
        /// </summary>
        /// <param name="r"></param>
        private static void ResponseCallBack(IAsyncResult r)
        {
            Stream     s     = null;
            AsyncState state = r.AsyncState as AsyncState;

            try
            {
                s = (state.r.EndGetResponse(r) as HttpWebResponse).GetResponseStream();
            }
            catch { }
            if (state.dele != null)
            {
                state.dele(s);
            }
            if (s == null)
            {
                return;
            }
            s.Close();
        }
예제 #5
0
 /// <summary>
 /// 开始请求
 /// </summary>
 /// <param name="state"></param>
 private static void AsyncRequest(AsyncState state)
 {
     try
     {
         state.r.BeginGetRequestStream(new AsyncCallback(RequestCallBack), state);
     }
     catch
     {
         if (state.dele != null)
             state.dele(null);
     }
 }
예제 #6
0
 /// <summary>
 /// 开始请求响应
 /// </summary>
 /// <param name="state"></param>
 private static void AsyncResponse(AsyncState state)
 {
     try
     {
         state.r.BeginGetResponse(new AsyncCallback(ResponseCallBack), state);
     }
     catch
     {
         if (state.dele != null)
             state.dele(null);
     }
 }