예제 #1
0
        public static void RunDownloadSync(IProgress <ProgressModel> progress)
        {
            List <string> websites = PrepData();

            foreach (string site in websites)
            {
                WebsiteDataModel results = DownloadWebsite(site);
            }
        }
예제 #2
0
        private static void TaskDone(Task <WebsiteDataModel> arg)
        {
            _doneSiteCont++;

            if (_progress != null)
            {
                ProgressModel progressModel = new ProgressModel();
                progressModel.Progess = _doneSiteCont * 100 / _totalSiteCount;

                WebsiteDataModel data = arg.Result;

                progressModel.WebSiteStatus = $"{  data.WebsiteUrl } downloaded: { data.WebsiteData.Length } characters long in {data.time_ms} ms .{ Environment.NewLine }";

                _progress.Report(progressModel);
            }
        }
예제 #3
0
        public static async Task <WebsiteDataModel> DownloadWebsiteAsync(string websiteURL)
        {
            WebsiteDataModel output = new WebsiteDataModel();
            WebClient        client = new WebClient();

            output.WebsiteUrl = websiteURL;

            var watch = System.Diagnostics.Stopwatch.StartNew();

            output.WebsiteData = await client.DownloadStringTaskAsync(websiteURL);

            watch.Stop();
            output.time_ms = watch.ElapsedMilliseconds;

            return(output);
        }
예제 #4
0
        public static WebsiteDataModel DownloadWebsite(string websiteURL)
        {
            WebsiteDataModel output = new WebsiteDataModel();
            WebClient        client = new WebClient();


            var watch = System.Diagnostics.Stopwatch.StartNew();

            output.WebsiteUrl  = websiteURL;
            output.WebsiteData = client.DownloadString(output.WebsiteUrl);

            watch.Stop();
            output.time_ms = watch.ElapsedMilliseconds;

            return(output);
        }
예제 #5
0
        public static void DownloadWebsite(string websiteURL, IProgress <ProgressModel> progress)
        {
            WebsiteDataModel output = new WebsiteDataModel();
            WebClient        client = new WebClient();

            output.WebsiteUrl = websiteURL;

            var watch = System.Diagnostics.Stopwatch.StartNew();

            output.WebsiteData = client.DownloadString(websiteURL);

            watch.Stop();
            output.time_ms = watch.ElapsedMilliseconds;

            _doneSiteCont++;
            ProgressModel progressModel = new ProgressModel();

            progressModel.Progess       = _doneSiteCont * 100 / _totalSiteCount;
            progressModel.WebSiteStatus = $"{ websiteURL } downloaded: { output.WebsiteData.Length } characters long in {output.time_ms} ms .{ Environment.NewLine }";
            _progress.Report(progressModel);
        }
예제 #6
0
 private void ReportWebsiteInfo(WebsiteDataModel data)
 {
     resultsWindow.Text += $"{ data.WebsiteUrl } downloaded: { data.WebsiteData.Length } characters long in {data.time_ms} ms .{ Environment.NewLine }";
 }
예제 #7
0
 public static async Task DownloadWebsiteAddToListAsync(string websiteURL)
 {
     WebsiteDataModel websiteDataModel = await DownloadWebsiteAsync(websiteURL);
 }