I have a System.Timers.Timer that updates my win form application components in every 5 seconds.
I have a comboBox and global IEnumerable<Person> list that updated also in everty 5 seconds.
I need to add persons name to combobox. If the name is already in the list, i should not add.
How can I proceed?
Here is the code inside the timer event. This adds multiple times and i am not sure to do that with foreach, maybe IEnumareble interface has an easier way.
foreach (Persons person in personsList)
{
comboBox.Items.Add(person.Name);
}
This is one of the simpler solutions to this problem, assuming you’re using .NET 3.5 or greater:
If you’re using 3.0 or earlier, you’ll have to do the search yourself: