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


C# WebClient.DownloadStringTask方法代码示例

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


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

示例1: InitContent

        private async void InitContent()
        {
           
            
            try{

            var client = new WebClient();
            string content="";
            
            content = await client.DownloadStringTask(new Uri("http://www.9gag.com/random"));
            string replaceWith = "";
            content = content.Replace("\r\n", replaceWith).Replace("\n", replaceWith).Replace("\r", replaceWith).Replace(" ", replaceWith);
            var s1 = content.Substring(content.IndexOf("img-wrap"));
            s1 = s1.Remove(0, 19);
            var  s2 = s1.Split('\"');

            ImageField.Source = new BitmapImage(new Uri("http:" + s2[0]));
            


          
                
                //titleBox.Text = jsonObject["title"].GetString();
                //string imgSource = "http:" + jsonObject["gag"].GetString();
                //var uri = new Uri(imgSource, UriKind.Absolute);
                //ImageField.Source = new BitmapImage(uri);
            }
            catch (Exception)
            {
                InitContent();
            }
            

        }
开发者ID:Cygarillo,项目名称:9GAGed_Mobile,代码行数:34,代码来源:MainPage.xaml.cs

示例2: Test

        async Test()
        {
            // download the google home page
            WebClient client = new WebClient();
            var google = client.DownloadStringTask("http://www.google.com");
            yield return google;
            // find and download the first link on the google home page
            Regex regex = new Regex("href=\"(?<href>http://.*?)\"");
            var match = regex.Match(google.Result);
            var firstHref = match.Groups["href"].Value;
            var firstHrefTask = client.DownloadStringTask(firstHref);
            yield return firstHrefTask;

            yield return new UIThreadTask(this);
            button.Text = firstHrefTask.Result.Substring(0, 10);
        }
开发者ID:koush,项目名称:AsyncTask,代码行数:16,代码来源:TestActivity.cs

示例3: LoadData

        public async void LoadData()
        {
            IsLoading = true;

            var client = new WebClient();

            try
            {
                string webcontent = await client.DownloadStringTask(new Uri("http://meteo.search.ch/" + Plz));


                string uriString = "http://meteo.search.ch/images/chart/" + GetImageUrl(webcontent);
                var source = new BitmapImage(new Uri(uriString));
                
                ImageSource = source;
                ExtractDescription(webcontent);

            }
            catch (Exception e) { }
            finally { IsLoading = false; }
        }
开发者ID:Cygarillo,项目名称:Waetter_Mobile,代码行数:21,代码来源:MainViewModel.cs

示例4: DoExecute

        /// <summary>
        /// 실제 작업을 정의합니다.
        /// </summary>
        /// <param name="context">Quartz <see cref="JobExecutionContext"/></param>
        /// <param name="token">작업중 중단를 할 수 있도록 하는 Token</param>
        public override void DoExecute(JobExecutionContext context, CancellationToken token) {
            var jobName = context.JobDetail.FullName;

            if(IsDebugEnabled)
                log.Debug(@"Job[{0}]을 시작합니다...", jobName);

            var targetUri = context.GetJobData("TargetUri") as Uri;

            using(var client = new WebClient()) {
                var task = client.DownloadStringTask(targetUri ?? new Uri(@"http://debop.egloos.com"));

                Task.WaitAll(new[] { task }, token);

                if(IsDebugEnabled) {
                    log.Debug("다운로드를 받았습니다.");
                    log.Debug(task.Result);
                }
            }

            if(IsDebugEnabled)
                log.Debug(@"Job[{0}]을 완료했습니다.", jobName);
        }
开发者ID:debop,项目名称:NFramework,代码行数:27,代码来源:WebPageDownloadServiceJob.cs

示例5: DispatcherTest

        async DispatcherTest()
        {
            // download the google home page
            WebClient client = new WebClient();
            var google = client.DownloadStringTask("http://www.google.com");
            yield return google;
            // find and download the first link on the google home page
            Regex regex = new Regex("href=\"(?<href>http://.*?)\"");
            var match = regex.Match(google.Result);
            var firstHref = match.Groups["href"].Value;
            var firstHrefTask = TaskHelper.Create(client.DownloadString, firstHref);
            yield return firstHrefTask;

            // let's yield back onto the Dispatcher to get onto the UI thread
            yield return this.Dispatcher();

            textBox1.Text = firstHrefTask.Result;
        }
开发者ID:koush,项目名称:AsyncTask,代码行数:18,代码来源:MainWindow.xaml.cs

示例6: Ping

 public void Ping() {
     using(var client = new WebClient()) {
         client.DownloadStringTask(GetScriptUrl()).Result.Should().Not.Be.Null();
     }
 }
开发者ID:debop,项目名称:NFramework,代码行数:5,代码来源:HttHandlerClientFixture.cs


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