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)
{
var tester = new DT2.UrlTester();
var stopWatch = new Stopwatch();
tester.PageStart += (_) =>
{
stopWatch.Start();
int size = new DT2.UrlTester().GetUrlSync(urlBox.Text);
};
tester.PageLoaded += (_, size) =>
{
stopWatch.Stop();
bytesBox.Text = $"{size} bytes";
timeBox.Text = $"{stopWatch.ElapsedMilliseconds} ms";
timeBar.Value = stopWatch.ElapsedMilliseconds;
};
_ = tester.GetUrlAsync(urlBox.Text);
}
}