private async void extractButton_Click(object sender, EventArgs e) { //Checks that ensures that a valid input was made if (textBox1.Text == string.Empty || textBox1.Text == " ") { MessageBox.Show("Textbox cannot be empty.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); textBox1.Text = string.Empty; return; } if (!Uri.IsWellFormedUriString(textBox1.Text, UriKind.Absolute)) { MessageBox.Show("URL is not in correct format", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); textBox1.Text = string.Empty; return; } imageList.Clear(); listBox1.Items.Clear(); fileExtension = null; url = textBox1.Text; label1.Text = "Extracting data."; //Async calling methods CallingMethodsAsync caller = new CallingMethodsAsync(); try { imageList = await caller.DownloadAsync(textBox1.Text); } catch (Exception ex) { MessageBox.Show(ex.Message, "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } foreach (var imageLink in imageList) { listBox1.Items.Add(imageLink); } if (imageList.Count == 0) { MessageBox.Show("No images found", "Results", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } label1.Text = string.Format("Found {0} images.", imageList.Count); }