Lock the list during reads and writes. Use List<struct> and Find() using
different Predicate delegates for your different search needs.
--
William Stacey [MVP]
[quoted text, click to view] "Jeff S." <A@B.COM> wrote in message
news:%231y7IKvUGHA.5500@TK2MSFTNGP12.phx.gbl...
| In a Windows Forms application I plan to have a collection of structs -
each
| of which contains a bunch of properties describing a person (e.g.,
LastName,
| FirstName, EmployeeID, HomeAddress, ZipCode, etc). So each instance of the
| struct will describe a person - and about 900 instances (people) will be
| contained in the collection.
|
| Users must be able to search for a specific person by any of the
properties
| (e.g., LastName, FirstName, EmployeeID, HomeAddress, ZipCode, etc). So the
| collection must be searchable by all of the properties of the contained
| struct instances.
|
| Please note that the comparison will be between (1) a string the user is
| typing into a textbox, and (2) the specified property (e.g., LastName) --
| such that AS the user types, a list displayed elsewhere on the form will
| dynamically show ALL of the closest matches (closest to the string the
user
| is typing AS the user types).
|
| The collection will periodically be updated on a background thread (every
15
| or so minutes) - so the collection must be "thread safe."
|
| MY QUESTIONS:
| 1. How do I make the collection of structs searchable by *each* of its
| properties (LastName, FirstName, Zip, etc...). Of course only one property
| at a time would be searched on. I would think implementing IComparable
would
| work - but apparently doing so would let me enable searching on only one
of
| the properties (but I need to enable searching on ALL of the properties).
|
| 2. How do I make the collection "thread safe" so that the collection can
be
| updated by a background thread while users may be searching for a person
in
| the collection. Note: people [in the collection] will almost never be
| deleted - so phantom matches are not really a concern.
|
| Just looking for high-level direction on this.
|
| Thank you very much!
|
|
|
|