예제 #1
0
        private void Progress_ProgressChanged(object sender, ProgressModel e)
        {
            progrBar.Value      = e.Progess;
            resultsWindow.Text += e.WebSiteStatus;

            if (progrBar.Value == 100)
            {
                stopwatch.Stop();
                var elapsedMs = stopwatch.ElapsedMilliseconds;
                resultsWindow.Text += $"Total execution time: { elapsedMs }";
            }
        }
예제 #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 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);
        }