I have a List called “myResults”. When the list contains at least one item, I’m trying to populate a GridView w/ info for the list; the GridView is called “gvMyResults”. However, sometimes, during this update of the DataSource, I get an exception saying, “Bounds cannot be changed while locked”, and a red X is displayed across my GridView. I added this Dispatcher wrapper around my update, but I’m still seeing the same error. It’s difficult to troubleshoot, because it does not happen every time. Does anyone know how to stop this “bounds cannot be changed while locked” error?
I have tried to fix this two ways, but both still give the error.
First attempt:
Dispatcher.CurrentDispatcher.Invoke(DispatcherPriority.Normal, (Action)delegate()
{
this.gvMyResults.DataSource = myResults;
});
Second attempt:
_Context.Send(x =>
{
this.gvMyResults.DataSource = myResults;
}, null);