I suppose it's pretty safe to assume that you can't know approximately what block of array elements is most likely to change, so...
You could kind of load-balance by divvying up index blocks among several threads. Since the number of elements is variable, I would setup some way to determine how big each array index block is on a per-thread basis, so for example, if you have 5000 elements, you could create 10 threads, and assign a block of 500 elements to each thread. This would make the change detection somewhat faster.
If you have over 50k elements, you could create more threads and/or watch larger blocks per thread.
It would be a challenging task to marshall all of these things, but I would personally get a real kick out of having to come up with a solution, if it were me.
It's too bad you're not using .Net 4, because it supports parallel tasking on a multi-cpu machine, and it's built just for problems like this.
BTW, this load-balancing approach would still require you to wqrap the array in an
ObservableCollection
of integers, and update those integers from from the array. I would probably build my items like this:
public class ArrayItem : IObservable
{
private Array[int] m_array = null;
private int m_value;
public int Value
{
get
{
return m_value;
}
set
{
m_value = value;
OnPropertyChanged("Value");
}
}
public int Index { get; set; }
public void OnPropertyChanged(string propertyName)
{
}
public ArrayItem(Array[] int source, int index)
{
m_array = source;
Index = index;
Value = m_array[Index];
}
public UpdateValue()
{
Value = m_array[Index];
}
}
Of course, you could probably avoid passing in the array if it's static and you can get to it anywhere in your app.