Question

I have my ViewModel with an ObservableCollection

private ObservableCollection<ObjectView> _elementList;
public ObservableCollection<ObjectView> ElementList
{
    get { return _elementList; }
    set { _elementList = value; RaisePropertyChanged("ElementList"); }
}

that is bind via an async thread when from TableView it's called a ReloadData (that is to have an endlessscroll on my TableView). I have noticed this error (that some time, not always, make it crash my app):

Feb 28 10:14:25 iPhone-di-Luigi JRUITouch[4518] <Warning>: CoreAnimation: warning, deleted thread with uncommitted CATransaction; created by:
0   QuartzCore                          0x31ce00a5 <redacted> + 268
1   QuartzCore                          0x31cdff59 <redacted> + 224
2   QuartzCore                          0x31ce05bb <redacted> + 30
3   QuartzCore                          0x31ce1f6b <redacted> + 158
4   QuartzCore                          0x31ce546d <redacted> + 40
5   UIKit                               0x3219a2c5 <redacted> + 48
6   UIKit                               0x321d0c65 <redacted> + 460
7   UIKit                               0x321d0a45 <redacted> + 68
8   CoreFoundation                      0x2f8240f3 <redacted> + 90
9   CoreFoundation                      0x2f824003 <redacted> + 198
10  UIKit                               0x3213a825 <redacted> + 628
11  LSUITouch                           0x001a24ec wrapper_managed_to_native_MonoTouch_ObjCRuntime_Messaging_void_objc_msgSend_intptr_intptr + 100
12  LSUITouch                           0x0017b948 MonoTouch_UIKit_UITableView_ReloadData + 52
13  LSUITouch                           0x00a210d4 Cirrious_MvvmCross_Binding_Touch_Views_MvxBaseTableViewSource_ReloadTableData + 176
14  LSUITouch                           0x00a24cf0 Cirrious_MvvmCross_Binding_Touch_Views_MvxTableViewSource_CollectionChangedOnCollectionChanged_object_System_Collections_Specialized_NotifyCollectionChangedEventArgs + 248

someone have an idea how to fix?

Était-ce utile?

La solution

Problem resolved via Stuart suggestion.

Update UI from outside threads it'll be dangerous...you could be some unexpected effects. Then each time that i add elements on my ObservableCollection i have called this update on main thread in that way:

private void AddElementsOnMainThread(AdvertObjectView item){
            MvxMainThreadDispatcher.Instance.RequestMainThreadAction((Action)delegate(){ 
                ElementList.Add(item);
            });
        }

in that way i have no more that warning and my UI thread it's protected from unexpected surprise!

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top