I am using an ObjectListView and trying to figure out how to correctly populate a field/column data asynchronously.
ObjectListView uses the concept of an "AspectSetter" which allows you to provide the content of the row's field data like so:
tlist.GetColumn(0).AspectGetter = delegate(Person x) { return x.Name; };
In my case, the field I am returning takes some time to calculate:
tlist.GetColumn(0).AspectGetter = delegate(Person x) { return SomeCalculation(); };
What would be the best approach to return the field data without blocking the UI and also allow the rest of the field data to be populated?
Create an
asyncmethod to perform the calculation and return the result.In the above code the calculation is performed on a background thread, preventing it from blocking the UI, and the
ObjectListViewis updated with the result on the UI thread when the calculation is completed.