Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do i add to the textBox the last updated index of the List<string> after comparing?
    primarykey
    data
    text
    <pre><code>private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e) { BackgroundWorker worker = sender as BackgroundWorker; while (true) { List&lt;string&gt; tempNamesAndTexts = new List&lt;string&gt;(); if ((worker.CancellationPending == true)) { e.Cancel = true; break; } else { string content = downloadContent(); GetProfileNames(content); GetTextFromProfile(content); for (int i = 0; i &lt; names.Count; i++) { tempNamesAndTexts.Add(names[i] + " " + texts[i]); namesAndTexts.Add(names[i] + " " + texts[i]); } if (InvokeRequired) { bool result = tempNamesAndTexts.SequenceEqual(namesAndTexts); if (result == true) { } else { foreach (string com in tempNamesAndTexts) { if (!namesAndTexts.Contains(com)) { MessageBox.Show(com); } } //BeginInvoke(new Action(() =&gt; namesAndTexts.ForEach(Item =&gt; textBox1.AppendText(Item + Environment.NewLine)))); } } reader.Close(); response.Close(); Thread.Sleep(1000); } } } </code></pre> <p>I have a List namesAndTexts in the Form1 level. And another temp local List tempNamesAndTexts</p> <p>What i need to do is in DoWork im updating the namesAndTexts every n seconds from a websites using the two functions in the DoWork.</p> <p>In the end i have the namesAndTexts List for exmaple:</p> <p>[0] Daniel hello [1] Moses hi</p> <p>I need to compare this namesAndTexts with the tempNamesAndTexts List and each time when its updating the List if they are the same dont do anything.</p> <p>But if they are not the same find what was didrenet in the two Lists and this different part only this add to the textBox.</p> <p>The problem is now that namesAndTexts all the time grow and grow 18 then 36 then 72 indexs its keeping adding the same strings over and over.</p> <hr> <p>What i need to do is:</p> <ol> <li><p>Download the content from a website every n seconds (downloadContent();)</p></li> <li><p>Create a List of names the GetProfileNames function.</p></li> <li><p>Create a List of texts GetTextFromProfile function.</p></li> <li><p>Create a List of the two Lists in 2. and 3. with names and text togeather.</p></li> <li><p>Store the old List in 4. to remember the last update.</p></li> <li><p>compare the last update with the new one. Compare the List in 5. with the one in 4.</p></li> <li><p>If the comparison result is true identical dont do anything.</p></li> <li><p>If the comparison is not identical find wich indexs in both Lists are not the same and add to the textBox the strings in the List wich are not the same with the other one.</p></li> </ol> <p>So the textBox should look like something, first once adding the List to the textBox for example:</p> <p>Daniel is here Modes is there Daniela is out</p> <p>Second time after comparison if its not identical find wich index/s is not identical and add only the string in this index/s to the textBox.</p> <p>So now the textBox will look like:</p> <p>Daniel is here Modes is there Daniela is out Yaron hello</p> <p>So the only change was that Yaron hell is now added to the textBox.</p> <p>But i cant figure out how to do it. Cant make the comparison of the wich indexs are not the same and take them out and add them to textBox cant figure out why one of the Lists keep growing up so in the next itertions the two lists are not identical but also there are no new indexs with names and texts to add to the textbox.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload