private async void RefreshBtn_Click(object sender, EventArgs e)
{
// Disable refresh spam
RefreshBtn.Enabled = false;
// Call Cancel Token
if (ServiceTask.Status == TaskStatus.Running)
{
TaskSource.Cancel();
// Wait for cancel to kick in
await ServiceTask;
}
// Dispose Task, and disable form actions
ServiceTask.Dispose();
this.Enabled = false;
// Reset the controls on this form to default
while (Controls.Count > 0)
Controls[0].Dispose();
// Redraw default controls
InitializeComponent();
// Enable this form
this.Enabled = true;
// Create new
TaskSource = new CancellationTokenSource();
ServiceTask = new Task(VerifyDnsCache, TaskSource.Token);
ServiceTask.Start();
}