当前位置: 首页>>代码示例>>C#>>正文


C# HttpWebRequest.BeginGetResponse方法代码示例

本文整理汇总了C#中System.Net.HttpWebRequest.BeginGetResponse方法的典型用法代码示例。如果您正苦于以下问题:C# HttpWebRequest.BeginGetResponse方法的具体用法?C# HttpWebRequest.BeginGetResponse怎么用?C# HttpWebRequest.BeginGetResponse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Net.HttpWebRequest的用法示例。


在下文中一共展示了HttpWebRequest.BeginGetResponse方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetRequest

 private void GetRequest(string word)
 {
     Uri reqUri = GetRequestUri(word);
     request = (HttpWebRequest)WebRequest.Create(reqUri);
     AsyncCallback callback = new AsyncCallback(ProcessRequest);
     request.BeginGetResponse(callback, null);
 }
开发者ID:ThyChief,项目名称:EnglishLib,代码行数:7,代码来源:DictionaryStorage.cs

示例2: Download

 public void Download(String URL)
 {
     URL = HttpUtility.UrlEncode(URL);
     string req_src = api_req_url + URL;
     wr = (HttpWebRequest)HttpWebRequest.Create(new Uri(req_src, UriKind.Absolute));
     wr.BeginGetResponse(new AsyncCallback(req_callback), wr);
 }
开发者ID:ahmeda8,项目名称:audio-youtube-wp7,代码行数:7,代码来源:youtub-org-api.cs

示例3: GetResponseAsync

        public Task<WebResponse> GetResponseAsync(HttpWebRequest request, int timeoutMs)
        {
            if (timeoutMs > 0)
            {
                return GetResponseAsync(request, TimeSpan.FromMilliseconds(timeoutMs));
            }

            var tcs = new TaskCompletionSource<WebResponse>();

            try
            {
                request.BeginGetResponse(iar =>
                {
                    try
                    {
                        var response = (HttpWebResponse)request.EndGetResponse(iar);
                        tcs.SetResult(response);
                    }
                    catch (Exception exc)
                    {
                        tcs.SetException(exc);
                    }
                }, null);
            }
            catch (Exception exc)
            {
                tcs.SetException(exc);
            }

            return tcs.Task;
        }
开发者ID:daltekkie,项目名称:Emby.ApiClient,代码行数:31,代码来源:PortableHttpWebRequestFactory.cs

示例4: AsyncGetResponse

        /// <summary>
        /// Encapsulates GetResponse so tests don't invoke the request
        /// </summary>
        /// <param name="req">Request to Twitter</param>
        /// <returns>Response to Twitter</returns>
        public static HttpWebResponse AsyncGetResponse(HttpWebRequest req)
        {
            Exception asyncException = null;

            var resetEvent = new ManualResetEvent(/*initialStateSignaled:*/ false);
            HttpWebResponse res = null;

            req.BeginGetResponse(
                new AsyncCallback(
                    ar =>
                    {
                        try
                        {
                            res = req.EndGetResponse(ar) as HttpWebResponse;
                        }
                        catch (Exception ex)
                        {
                            asyncException = ex;
                        }
                        finally
                        {
                            resetEvent.Set();
                        }
                    }), null);

            resetEvent.WaitOne();

            if (asyncException != null)
            {
                throw asyncException;
            }

            return res;
        }
开发者ID:prog-moh,项目名称:LinqToTwitter,代码行数:39,代码来源:Utilities.cs

示例5: BeginGetHeight

    public void BeginGetHeight(XYPoint point, int UTMZone)
    {
      string url = String.Format("http://kmswww3.kms.dk/FindMinHoejde/Default.aspx?display=show&csIn=utm{2}_euref89&csOut=utm32_euref89&x={0}&y={1}&c=dk", point.X, point.Y, UTMZone);

      request = (HttpWebRequest)WebRequest.Create(url);
      result= (IAsyncResult) request.BeginGetResponse(new AsyncCallback(RespCallback),null);
    }
开发者ID:XiBeichuan,项目名称:hydronumerics,代码行数:7,代码来源:KMSData.cs

示例6: GetResponseAsynch

 private HttpWebResponse GetResponseAsynch(HttpWebRequest request)
 {
     return AsynchHelper.WaitForAsynchResponse(
         c => request.BeginGetResponse(c, null),
         (r, s) => (HttpWebResponse)request.EndGetResponse(r)
     );
 }
开发者ID:sergioazevedo,项目名称:restfulie-net,代码行数:7,代码来源:DefaultRequestDispatcher.cs

示例7: FetchSearchResults

        public void FetchSearchResults(HttpWebRequest queryRequest)
        {
            this.WebResultCollection.Clear();

            IsLoading = true;

            queryRequest.BeginGetResponse(new AsyncCallback(ReadCallback), queryRequest);
        }
开发者ID:NewETown,项目名称:WP8.Re,代码行数:8,代码来源:ResultViewModel.cs

示例8: button_Click

        private void button_Click(object sender, RoutedEventArgs e)
        {
            if (list.Items.Count != 0)
                list.Items.Clear();

            http = (HttpWebRequest)WebRequest.Create("http://192.168.2.39/TOSWEB/webservice/service.php");
            http.BeginGetResponse(new AsyncCallback(ReadWebRequestCallBack), http);
        }
开发者ID:DF001,项目名称:TOS,代码行数:8,代码来源:MainPage.xaml.cs

示例9: OnNavigatedTo

        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            DownloadStatusText.Text = "Downloading image from " + imageUrl;
            webRequest = (HttpWebRequest)HttpWebRequest.CreateHttp(imageUrl);
            webRequest.BeginGetResponse(new AsyncCallback(ResponseCallback), webRequest);

            base.OnNavigatedTo(e);
        }
开发者ID:trilok567,项目名称:Windows-Phone,代码行数:8,代码来源:GetImagePage.xaml.cs

示例10: IssueRequest

        public static IEnumerator<object> IssueRequest(HttpWebRequest request)
        {
            var fResponse = new Future<HttpWebResponse>();
            ThreadPool.QueueUserWorkItem(
                (__) => {
                    try {
                        request.BeginGetResponse(
                            (ar) => {
                                try {
                                    var _ = (HttpWebResponse)request.EndGetResponse(ar);
                                    fResponse.SetResult(_, null);
                                } catch (Exception ex) {
                                    fResponse.SetResult(null, ex);
                                }
                            }, null
                        );
                    } catch (Exception ex_) {
                        fResponse.SetResult(null, ex_);
                    }
                }
            );

            yield return fResponse;
            if (fResponse.Failed)
                throw new RequestFailedException(fResponse.Error);

            using (var response = fResponse.Result) {
                var fResponseStream = Future.RunInThread(
                    () => response.GetResponseStream()
                );
                yield return fResponseStream;

                Encoding encoding = AsyncTextReader.DefaultEncoding;
                if (!string.IsNullOrEmpty(response.CharacterSet))
                    encoding = Encoding.GetEncoding(response.CharacterSet);

                string responseText;
                using (var stream = fResponseStream.Result)
                using (var adapter = new AsyncTextReader(new StreamDataAdapter(stream, false), encoding)) {
                    var fText = adapter.ReadToEnd();

                    yield return fText;

                    responseText = fText.Result;
                }

                var cookies = new Cookie[response.Cookies.Count];
                response.Cookies.CopyTo(cookies, 0);

                yield return new Result(new Response {
                    Body = responseText,
                    ContentType = response.ContentType,
                    StatusCode = response.StatusCode,
                    StatusDescription = response.StatusDescription,
                    Cookies = cookies
                });
            }
        }
开发者ID:pakoito,项目名称:Fracture,代码行数:58,代码来源:Web.cs

示例11: SendCommandAsync

        public void SendCommandAsync(JsonAsyncCallback jCallback)
        {
            jb = jCallback;
            //String qryString = uri + name + "?" + (secret != Guid.Empty ? ("secret=" + secret.ToString() + "&") : "") + paramString;
            String qryString = uri + name + "?" + paramString;

            request = (HttpWebRequest)HttpWebRequest.Create(qryString);
            IAsyncResult result = (IAsyncResult)request.BeginGetResponse(RespCallback, null);
        }
开发者ID:Boris0190,项目名称:WRS20,代码行数:9,代码来源:HTTPCommand.cs

示例12: SendMinecraftNetBeat

 static void SendMinecraftNetBeat() {
     HeartbeatData data = new HeartbeatData( MinecraftNetUri );
     if( !RaiseHeartbeatSendingEvent( data, MinecraftNetUri, true ) ) {
         return;
     }
     minecraftNetRequest = CreateRequest( data.CreateUri() );
     var state = new HeartbeatRequestState( minecraftNetRequest, data );
     minecraftNetRequest.BeginGetResponse( ResponseCallback, state );
 }
开发者ID:fragmer,项目名称:fCraft,代码行数:9,代码来源:Heartbeat.cs

示例13: GetData

 public void GetData()
 {
     using (var File = IsolatedStorageFile.GetUserStoreForApplication())
     {
         request = (HttpWebRequest)HttpWebRequest.Create("http://www.search4rss.com/search.php?lang=en&q=" + txt_Search.Text);
         Dispatcher.BeginInvoke(() => RssList.Visibility=Visibility.Collapsed);
         Dispatcher.BeginInvoke(() => Loading_for_Search.Visibility=Visibility.Visible);
         request.BeginGetResponse(new AsyncCallback(ReadWebRequestCallback), request);
     }
 }
开发者ID:jsandip57,项目名称:PinUrRss,代码行数:10,代码来源:MainPage.xaml.cs

示例14: DownloadDataAsync

        public void DownloadDataAsync(HttpWebRequest request, byte[] d,  int millisecondsTimeout,
           RequestCompletedEventHandler completedCallback)
        {
            RequestState state = new RequestState(request, d, millisecondsTimeout, completedCallback, null);

            IAsyncResult result = request.BeginGetResponse(GetResponse, state);

#if !NETFX_CORE
            ThreadPool.RegisterWaitForSingleObject(result.AsyncWaitHandle, TimeoutCallback, state, millisecondsTimeout, true);
#endif
        }
开发者ID:nextropia,项目名称:GoogleMusicAPI.NET,代码行数:11,代码来源:HTTP.cs

示例15: GetAsync

 /// <summary>Attempts to get data from a web request.</summary>
 /// <param name="request">The HTTP web request.</param>
 /// <param name="method">The OneAll supported HTTP method to use.</param>
 /// <param name="creds">The <see cref="Credential"/> used to authenticate the call, or null for calls not requiring authentication.</param>
 /// <param name="callBack">The call-back to invoke after the request is complete.</param>
 /// <param name="state">The initial state object provided.</param>
 private static void GetAsync(HttpWebRequest request, OneAllMethod method, Credential creds, BinaryReceivedHandler callBack, object state)
 {
     request.SetHTTPMethod(method);
     request.SetBasicAuth(creds);
     request.BeginGetResponse(OnRequestCompleted, new BinaryWebClientState()
     {
         Request = request,
         Callback = callBack,
         State = state
     });
 }
开发者ID:K232,项目名称:OneAll,代码行数:17,代码来源:BinaryWebClient.cs


注:本文中的System.Net.HttpWebRequest.BeginGetResponse方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。