Run URL check using a task
This commit is contained in:
parent
94cb10b3df
commit
08f6288f91
1 changed files with 16 additions and 5 deletions
|
@ -25,11 +25,22 @@ public partial class MainWindow : Window
|
||||||
|
|
||||||
public void GetUrl(object sender, RoutedEventArgs e)
|
public void GetUrl(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
|
var tester = new DT2.UrlTester();
|
||||||
var stopWatch = new Stopwatch();
|
var stopWatch = new Stopwatch();
|
||||||
|
|
||||||
|
tester.PageStart += (_) =>
|
||||||
|
{
|
||||||
stopWatch.Start();
|
stopWatch.Start();
|
||||||
int size = new DT2.UrlTester().GetUrlSync(urlBox.Text);
|
};
|
||||||
|
|
||||||
|
tester.PageLoaded += (_, size) =>
|
||||||
|
{
|
||||||
stopWatch.Stop();
|
stopWatch.Stop();
|
||||||
bytesBox.Text = $"{size} bytes";
|
bytesBox.Text = $"{size} bytes";
|
||||||
timeBox.Text = $"{stopWatch.ElapsedMilliseconds} ms";
|
timeBox.Text = $"{stopWatch.ElapsedMilliseconds} ms";
|
||||||
|
timeBar.Value = stopWatch.ElapsedMilliseconds;
|
||||||
|
};
|
||||||
|
|
||||||
|
_ = tester.GetUrlAsync(urlBox.Text);
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue