I have a timer tick event:
private void timer2_Tick(object sender, EventArgs e)
{
combindedString = string.Join(Environment.NewLine, ListsExtractions.myList);
richTextBox1.SelectAll();
richTextBox1.SelectionAlignment = HorizontalAlignment.Right;
richTextBox1.Text = combindedString;
}
The timer is set to 50000 and the time is running all the time over and over again.
Now the List<string> myList
when i'm running my program has, for example, 3 items:
Index 0: Hello world
Index 1: 24/7/2014 21:00
Index 2: http://test.com
After 50 seconds there are two options: either the List not changed or it has changed/longer.
If not changed do nothing but if changed get the latest added item. For example, if the list has now been changed to this...
Index 0: This is the latest item added in index 0
Index 1: 24/7/2014 22:00
Index 2: http://www.google.com
Index 3: ""
Index 4: Hello world
Index 5: 24/7/2014 21:00
Index 6: http://test.com
... then I need to do another two actions:
When running the program for the first time, check if the most recent item (the string at Index 0
in this example) contains two words/strings. If it does, then do something, otherwise, do nothing.
However, if it does contain the words/strings and we do "do something", only do it once after 50 seconds; don't do it again even if the words/string exist again in index 0.
After 50 seconds if the List changed and in Index 0
this words/strings exists, do something and again only once after 50 seconds. If the List didn't change, don't do it again even if the words/string still exist in index 0.
if (rlines[0].Contains("??? ????") || rlines[0].Contains("?????"))
{
timer3.Start();
}
I want to start timer3
only if one of the words/strings exist in index 0.
If nothing has changed after 50 seconds don't start timer3
again.
Only if after 50 seconds or later the List changed and one of the words/strings exist in index 0 again only then start timer 3 again.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…