This project is read-only.

Crashes in multi threaded application

Apr 27, 2009 at 12:39 AM
I found when using ClickAndQuery example (see my previous post) that the app crashes with large resultset. However, I could reproduce this easily when adding items through a worker thread in a multi threaded app. It seems that _rowInformation object is null during call to HandleSyncing. Sync in background option is set with _listControl1.Items.ProcessingStyle = BinaryComponents.SuperList.ItemLists.ProcessingStyle.Thread;

I am very new to C#. I will appreciate if someone can share their expertise on this.

The stack trace  

System.NullReferenceException: Object reference not set to an instance of an object.
at BinaryComponents.SuperList.Sections.ListSection.CalculateListItems() in ..\Winforms\ListView\SuperList\Main\BinaryComponents.SuperList\Sections\ListSection.cs:line 1578
at BinaryComponents.SuperList.Sections.ListSection.Layout(GraphicsSettings gs, Size maximumSize) in ..\Winforms\ListView\SuperList\Main\BinaryComponents.SuperList\Sections\ListSection.cs:line 279
at BinaryComponents.SuperList.Sections.ListSection.Layout() in ..\Winforms\ListView\SuperList\Main\BinaryComponents.SuperList\Sections\ListSection.cs:line 1214
at BinaryComponents.SuperList.Sections.ListSection.ListUpdated(Boolean lazyLayout) in ..\Winforms\ListView\SuperList\Main\BinaryComponents.SuperList\Sections\ListSection.cs:line 802
at BinaryComponents.SuperList.ListControl.UpdateListSection(Boolean lazyLayout) in ..\Winforms\ListView\SuperList\Main\BinaryComponents.SuperList\ListControl.cs:line 587
at BinaryComponents.SuperList.ItemLists.ItemList.ListUpdated(Boolean lazyLayout) in ..\Winforms\ListView\SuperList\Main\BinaryComponents.SuperList\ItemList\ItemList.cs:line 147
at BinaryComponents.SuperList.ItemLists.BufferedList.CheckForJobCompletionResults() in ..\Winforms\ListView\SuperList\Main\BinaryComponents.SuperList\ItemList\BufferedItemList.cs:line 234
at BinaryComponents.SuperList.ItemLists.BufferedList.DoHouseKeeping(Boolean runInBackground) in ..\Winforms\ListView\SuperList\Main\BinaryComponents.SuperList\ItemList\BufferedItemList.cs:line 199
at BinaryComponents.SuperList.ItemLists.BufferedList.DoHouseKeeping() in ..\Winforms\ListView\SuperList\Main\BinaryComponents.SuperList\ItemList\BufferedItemList.cs:line 190
at BinaryComponents.SuperList.ListControl._timer_Tick(Object sender, EventArgs e) in ..\Winforms\ListView\SuperList\Main\BinaryComponents.SuperList\ListControl.cs:line 548
at System.Windows.Forms.Timer.OnTick(EventArgs e)
at System.Windows.Forms.Timer.TimerNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
Apr 27, 2009 at 9:06 AM
Hi I will look into this next week - I'm really busy at the moment on a couple of contracts I have to get finished, but I will get onto it after....

Apr 28, 2009 at 3:49 PM
Edited Apr 28, 2009 at 4:09 PM
Thanks for your support. Another multi threaded related issue I found was that selecting an item while list is being populated in another thread.

My code:
//sort in background
listControl1.Items.ProcessingStyle = BinaryComponents.SuperList.ItemLists.ProcessingStyle.Thread;

//select an item
RowIdentifier ri = this._listControl1.SelectedItems[0]; //-> crashes with IndexOutofRangeException

I digged into it and seems that _selectedRows is null in the GetSortedSelectionList method in SelectedItemsCollection.cs.

private RowIdentifier[] GetSortedSelectionList()
            RowIdentifier[] selectedItemsArray = _selectedItemsArrayRef == null ? null : (RowIdentifier[])_selectedItemsArrayRef.Target;
            if( selectedItemsArray == null )
                List<RowIdentifier> items = new List<RowIdentifier>( _selectedRows.Count );
                List<object> keys = new List<object>( _selectedRows.Count );
                foreach( KeyValuePair<RowIdentifier, int> kv in _selectedRows )
                    items.Add( kv.Key );
                    keys.Add( kv.Value );
                RowIdentifier[] itemsArray = items.ToArray();
                Array.Sort( keys.ToArray(), itemsArray );
                selectedItemsArray = items.ToArray();
                _selectedItemsArrayRef = new WeakReference( selectedItemsArray );
            return selectedItemsArray;

This causes the following property to throw IndexOutOfRange exception
 RowIdentifier this[int i]
                return GetSortedSelectionList()[i];

Thanks again!

Nov 16, 2012 at 3:19 AM


I am facing the same issue that rudrafavor has posted above on Apr 27, 2009. Can you please advice if this problem is already addressed in a later release. Or is there some way in which I can handle this situation? Any help would be appreciated.

Regards, Srividya