Beispiel #1
0
 private void UpdateReadProgress(ReadProgress rProgress)
 {
     this.progressBar.InvokeIfRequired(() =>
     {
         this.progressBar.Value = rProgress.ReadingPercent;
     });
 }
Beispiel #2
0
        private async Task <string> GetWebContents(string url, IProgress <ReadProgress> progress)
        {
            WebClient cl = new WebClient();

            cl.Encoding = Encoding.UTF8;
            string s = await cl.DownloadStringTaskAsync(new Uri(url));

            if (progress != null)
            {
                var rprogress = new ReadProgress(++this.downDoneCnt, this.downTotalCnt);
                progress.Report(rprogress);
            }
            return(s);

            //string content = cl.DownloadString(url);
            //return "\r\n\r\n\r\n\r\n\r\n符号只是为了方便测试时候确定内容是从某个网址下载的\r\n==============" + url + "=================\r\n\r\n\r\n\r\n" + content;
        }