Dear Rocky, dear all,
CSLA rocks and we are using it more and more with time.
However, we highlighted what seems to be a bug due to multi threading in the SaveItem(int index) implementation.
Here is some simple steps to reproduce:
Implement a DLB and BindingBase, with a Thread.Spleep(10000) in the update.
Bind a grid with a DLB containing 2 items.
Remove the first item and edit the second item (before the remove asynch call returns).
The second item will fail to save, because the handler will try to update index=1 (which does not exist anymore as the list now as only 1 item).
Is anyone else facing the same trouble?
We implemented the following fix (l.152 / DLB.SaveItem(int index):
// save object
DataPortal<T> dp = new DataPortal<T>();
dp.UpdateCompleted += (o, e) =>
//FIX BEGIN- The original index may not be valid anymore, if a delete was done during that save.
index = this.IndexOf(item);
I do not know if any other code is affected by the same trouble, but the fix is quite straighforward.
Does anyone see any risk with that fix?
Already registered in Bugtracker: http://www.lhotka.net/cslabugs/edit_bug.aspx?id=932
Your fix looks correct to me but we will investigate further.
I have also added link to your post in bugtracker.
Thanks for the amazing fast answer. Any idea of roadmap to include the fix in the official release/trunk?
I saw that the issue is tracked in BugTracker for a few months and it looks like a serious issue (and difficult to understand like all concurrency issues) that other users are probably facing too.
I noticed the priority is high so hopefully - it will make it into 4.3.
I'll start to look into it later this evening.
Copyright (c) Marimer LLC