I have this code :
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
{
BackgroundWorker worker = sender as BackgroundWorker;
while (true)
{
if ((worker.CancellationPending == true))
{
e.Cancel = true;
break;
}
else
{
string content = downloadContent();
if (InvokeRequired)
{
BeginInvoke(new Action(() => textBox1.Text = content), null);
}
GetProfileNames(content);
GetTextFromProfile(content);
reader.Close();
response.Close();
Thread.Sleep(30000);
}
}
}
And the downloadContent function:
private string downloadContent()
{
WebRequest request = WebRequest.Create(testingUrl);
request.Method = "GET";
response = request.GetResponse();
Stream stream = response.GetResponseStream();
reader = new StreamReader(stream);
string content = reader.ReadToEnd();
return content;
}
I need that every 30 seconds it will download a new content like it does now, store the old content one before and compare the new download with the one before downloaded content.
If they are identical dont do anything if they are not identical do something.
Keep a variable to store the last content. This variable should be placed outside the BGWorker DoWork method.
Then, under this line:
Add these to see if they are same or not: