Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private async void btnTestConn_Click(object sender, EventArgs e)
- {
- async Task<bool> test_networkAsync()
- {
- Stopwatch sw = new Stopwatch();
- try
- {
- //sw.Start();
- using (var client = new System.Net.WebClient())
- using (var stream = await client.OpenReadTaskAsync("https://www.youtube.com"))
- {
- //sw.Stop();
- //Console.WriteLine(sw.Elapsed);
- return true;
- }
- }
- catch
- {
- return false;
- }
- }
- // I put it in the loop in order to testing.
- for (int i = 0; i < 5; ++i)
- {
- await test_networkAsync();
- }
- }
Add Comment
Please, Sign In to add comment