Run URL check using a task

This commit is contained in:
Manuel Thalmann 2024-03-22 00:56:40 +01:00
parent 94cb10b3df
commit 08f6288f91

View file

@ -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);
} }
} }