I'm trying to use my own safe observable collection as the Item source for the grid.
What I've done for testing purposes is this:
1. Open a new thread
2. Create a lot of data in that thread
3. Clear the item source that's already binded to the radGridView (the collection being cleared is done in the thread, the call to CollectionChanged is invoked to the dispatcher)
4. add all of the items in the disconnected list to the ItemSource, every addition makes a separate invocation to the dispatcher to call CollectionChanged.
At a random point during 4 I'll get the exception, could be on the first addition could be on 200th (let's say I have 1000 items in the collection), what I've found by logging everything that happens in my observable collection is that the random point is the one after the grid calls GetEnumerator, I've made sure that the enumeration has ended before I touch the collection by using a reader writer lock and the addition only happens after the enumerator is disposed.
What I've done for testing purposes is this:
1. Open a new thread
2. Create a lot of data in that thread
3. Clear the item source that's already binded to the radGridView (the collection being cleared is done in the thread, the call to CollectionChanged is invoked to the dispatcher)
4. add all of the items in the disconnected list to the ItemSource, every addition makes a separate invocation to the dispatcher to call CollectionChanged.
At a random point during 4 I'll get the exception, could be on the first addition could be on 200th (let's say I have 1000 items in the collection), what I've found by logging everything that happens in my observable collection is that the random point is the one after the grid calls GetEnumerator, I've made sure that the enumeration has ended before I touch the collection by using a reader writer lock and the addition only happens after the enumerator is disposed.
mscorlib.dll!System.ThrowHelper.ThrowArgumentOutOfRangeException(System.ExceptionArgument argument, System.ExceptionResource resource) + 0x41 bytes
mscorlib.dll!System.Collections.Generic.List<
object
>.Insert(int index, object item) + 0x82 bytes
Telerik.Windows.Data.dll!Telerik.Windows.Data.KeyedCollection.Insert(int index, object value) Line 181 C#
Telerik.Windows.Data.dll!Telerik.Windows.Data.QueryableCollectionView.ProcessSynchronousCollectionChanged(System.Collections.Specialized.NotifyCollectionChangedEventArgs args) Line 1479 C#
Telerik.Windows.Data.dll!Telerik.Windows.Data.QueryableCollectionView.ProcessCollectionChanged(System.Collections.Specialized.NotifyCollectionChangedEventArgs args) Line 1342 C#
Telerik.Windows.Data.dll!Telerik.Windows.Data.QueryableCollectionView.OnSourceCollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs args) Line 1819 C#
Telerik.Windows.Data.dll!Telerik.Windows.Data.QueryableCollectionView.Telerik.Windows.Data.IWeakEventListener<
System.Collections.Specialized.NotifyCollectionChangedEventArgs
>.ReceiveWeakEvent(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs args) Line 1798 C#
Telerik.Windows.Data.dll!Telerik.Windows.Data.WeakEvent.WeakListener<
System.Collections.Specialized.NotifyCollectionChangedEventArgs
>.Handler(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs args) Line 33 + 0x42 bytes C#
> TestInfragisticsGrid.exe!TelerikTest3.SafeObservable<
TelerikTest3.Employee
>.DoAdd(TelerikTest3.Employee item) Line 77 + 0x34 bytes C#
TestInfragisticsGrid.exe!TelerikTest3.SafeObservable<
TelerikTest3.Employee
>.Add.AnonymousMethod__2() Line 67 + 0x12 bytes C#
WindowsBase.dll!System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate callback, object args, int numArgs) + 0xba bytes
WindowsBase.dll!MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(object source, System.Delegate method, object args, int numArgs, System.Delegate catchHandler) + 0x42 bytes
WindowsBase.dll!System.Windows.Threading.DispatcherOperation.InvokeImpl() + 0x8d bytes
WindowsBase.dll!System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(object state) + 0x38 bytes
mscorlib.dll!System.Threading.ExecutionContext.runTryCode(object userData) + 0x51 bytes
[Native to Managed Transition]
[Managed to Native Transition]
mscorlib.dll!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state) + 0x6a bytes
mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool ignoreSyncCtx) + 0x7e bytes
mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state) + 0x2c bytes
WindowsBase.dll!System.Windows.Threading.DispatcherOperation.Invoke() + 0x68 bytes
WindowsBase.dll!System.Windows.Threading.Dispatcher.ProcessQueue() + 0x15e bytes
WindowsBase.dll!System.Windows.Threading.Dispatcher.WndProcHook(System.IntPtr hwnd, int msg, System.IntPtr wParam, System.IntPtr lParam, ref bool handled) + 0x63 bytes
WindowsBase.dll!MS.Win32.HwndWrapper.WndProc(System.IntPtr hwnd, int msg, System.IntPtr wParam, System.IntPtr lParam, ref bool handled) + 0xbe bytes
WindowsBase.dll!MS.Win32.HwndSubclass.DispatcherCallbackOperation(object o) + 0x7d bytes
WindowsBase.dll!System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate callback, object args, int numArgs) + 0x53 bytes
WindowsBase.dll!MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(object source, System.Delegate method, object args, int numArgs, System.Delegate catchHandler) + 0x42 bytes
WindowsBase.dll!System.Windows.Threading.Dispatcher.InvokeImpl(System.Windows.Threading.DispatcherPriority priority, System.TimeSpan timeout, System.Delegate method, object args, int numArgs) + 0xb4 bytes
WindowsBase.dll!MS.Win32.HwndSubclass.SubclassWndProc(System.IntPtr hwnd, int msg, System.IntPtr wParam, System.IntPtr lParam) + 0x104 bytes
[Native to Managed Transition]
[Managed to Native Transition]
System.Windows.Forms.dll!System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(System.IntPtr dwComponentID, int reason, int pvLoopData) + 0x287 bytes
System.Windows.Forms.dll!System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(int reason, System.Windows.Forms.ApplicationContext context) + 0x16c bytes
System.Windows.Forms.dll!System.Windows.Forms.Application.ThreadContext.RunMessageLoop(int reason, System.Windows.Forms.ApplicationContext context) + 0x61 bytes
System.Windows.Forms.dll!System.Windows.Forms.Application.Run(System.Windows.Forms.Form mainForm) + 0x31 bytes
TestInfragisticsGrid.exe!TelerikTest3.Program.Main() Line 18 + 0x1d bytes C#
[Native to Managed Transition]
[Managed to Native Transition]
mscorlib.dll!System.AppDomain.ExecuteAssembly(string assemblyFile, System.Security.Policy.Evidence assemblySecurity, string[] args) + 0x6d bytes
Microsoft.VisualStudio.HostingProcess.Utilities.dll!Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() + 0x2a bytes
mscorlib.dll!System.Threading.ThreadHelper.ThreadStart_Context(object state) + 0x63 bytes
mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool ignoreSyncCtx) + 0xb0 bytes
mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state) + 0x2c bytes
mscorlib.dll!System.Threading.ThreadHelper.ThreadStart() + 0x44 bytes
[Native to Managed Transition]