Beispiel #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);
         }
     }
 }
Beispiel #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);
         }
     }
 }
Beispiel #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);
                }
            }
        }
Beispiel #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();
        }
Beispiel #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);
     }
 }
Beispiel #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);
     }
 }