Hi,
I'll just reopend this issue - I just tested it with v2.6 but the reported issue still exists!
* I am starting a window in its own UI thread.
* The window contains a propertygrid. At some time I close the window and stop the dispatcher.
* At a later stage I decide to start a new instance of the same window class in new UI Thread (with it's own dispatcher).
* When this window is created, I get the exception reported below
```
exception Details (key=value): (System.Object=) System.InvalidOperationException: The calling thread cannot access this object because a different thread owns it.
at System.Windows.Threading.Dispatcher.VerifyAccess()
at System.Windows.Threading.DispatcherObject.VerifyAccess()
at System.Windows.SystemResources.FindCachedResource(Object key, Object& resource, Boolean mustReturnDeferredResourceReference)
at System.Windows.SystemResources.FindResourceInternal(Object key, Boolean allowDeferredResourceReference, Boolean mustReturnDeferredResourceReference)
at System.Windows.FrameworkElement.FindResourceInternal(FrameworkElement fe, FrameworkContentElement fce, DependencyProperty dp, Object resourceKey, Object unlinkedParent, Boolean allowDeferredResourceReference, Boolean mustReturnDeferredResourceReference, DependencyObject boundaryElement, Boolean isImplicitStyleLookup, Object& source)
at System.Windows.FrameworkElement.FindResource(Object resourceKey)
at Xceed.Wpf.Toolkit.PropertyGrid.PropertyGrid.UpdateContainerHelper() in z:\Test\PropertyGridTest\ToolkitSrc\Main\Source\ExtendedWPFToolkitSolution\Src\Xceed.Wpf.Toolkit\PropertyGrid\Implementation\PropertyGrid.cs:line 888
at Xceed.Wpf.Toolkit.PropertyGrid.PropertyGrid.OnSelectedObjectChanged(Object oldValue, Object newValue) in z:\Test\PropertyGridTest\ToolkitSrc\Main\Source\ExtendedWPFToolkitSolution\Src\Xceed.Wpf.Toolkit\PropertyGrid\Implementation\PropertyGrid.cs:line 452
at Xceed.Wpf.Toolkit.PropertyGrid.PropertyGrid.OnSelectedObjectChanged(DependencyObject o, DependencyPropertyChangedEventArgs e) in z:\Test\PropertyGridTest\ToolkitSrc\Main\Source\ExtendedWPFToolkitSolution\Src\Xceed.Wpf.Toolkit\PropertyGrid\Implementation\PropertyGrid.cs:line 440
at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
at Xceed.Wpf.Toolkit.PropertyGrid.PropertyGrid.OnPropertyChanged(DependencyPropertyChangedEventArgs e) in z:\Test\PropertyGridTest\ToolkitSrc\Main\Source\ExtendedWPFToolkitSolution\Src\Xceed.Wpf.Toolkit\PropertyGrid\Implementation\PropertyGrid.cs:line 807
at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)
at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType)
at System.Windows.DependencyObject.InvalidateProperty(DependencyProperty dp, Boolean preserveCurrentValue)
at System.Windows.Data.BindingExpressionBase.Invalidate(Boolean isASubPropertyChange)
at System.Windows.Data.BindingExpression.TransferValue(Object newValue, Boolean isASubPropertyChange)
at System.Windows.Data.BindingExpression.Activate(Object item)
at System.Windows.Data.BindingExpression.AttachToContext(AttachAttempt attempt)
at System.Windows.Data.BindingExpression.MS.Internal.Data.IDataBindEngineClient.AttachToContext(Boolean lastChance)
at MS.Internal.Data.DataBindEngine.Task.Run(Boolean lastChance)
at MS.Internal.Data.DataBindEngine.Run(Object arg)
at MS.Internal.Data.DataBindEngine.OnLayoutUpdated(Object sender, EventArgs e)
at System.Windows.ContextLayoutManager.fireLayoutUpdateEvent()
at System.Windows.ContextLayoutManager.UpdateLayout()
at System.Windows.ContextLayoutManager.UpdateLayoutCallback(Object arg)
at System.Windows.Media.MediaContext.InvokeOnRenderCallback.DoWork()
at System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks()
at System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget)
at System.Windows.Media.MediaContext.RenderMessageHandler(Object resizedCompositionTarget)
at System.Windows.Media.MediaContext.Resize(ICompositionTarget resizedCompositionTarget)
at System.Windows.Interop.HwndTarget.OnResize()
at System.Windows.Interop.HwndTarget.HandleMessage(WindowMessage msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Interop.HwndSource.HwndTargetFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
```
For me it seems like the new property grid in the window is caching some data created by the previous UI thread. I just cannot find out what it is.
Do you have any idea?
Comments: ** Comment from web user: cls71 **
Hello,
This issue persists in the current version 2.6.0 Community Edition.
2016-04-03 12:54:39:710 Starting server message polling timer with interval 3600 seconds...
2016-04-03 12:56:44:117 *************** unhandled exception trapped ***************
2016-04-03 12:56:44:117 The calling thread cannot access this object because a different thread owns it.
2016-04-03 12:56:44:117 System.InvalidOperationException: The calling thread cannot access this object because a different thread owns it.
at System.Windows.Threading.Dispatcher.VerifyAccess()
at System.Windows.SystemResources.FindCachedResource(Object key, Object& resource, Boolean mustReturnDeferredResourceReference)
at System.Windows.SystemResources.FindResourceInternal(Object key, Boolean allowDeferredResourceReference, Boolean mustReturnDeferredResourceReference)
at System.Windows.FrameworkElement.FindResourceInternal(FrameworkElement fe, FrameworkContentElement fce, DependencyProperty dp, Object resourceKey, Object unlinkedParent, Boolean allowDeferredResourceReference, Boolean mustReturnDeferredResourceReference, DependencyObject boundaryElement, Boolean isImplicitStyleLookup, Object& source)
at System.Windows.FrameworkElement.FindResource(Object resourceKey)
at Xceed.Wpf.Toolkit.PropertyGrid.PropertyGrid.UpdateContainerHelper()
at Xceed.Wpf.Toolkit.PropertyGrid.PropertyGrid.OnSelectedObjectChanged(Object oldValue, Object newValue)
at Xceed.Wpf.Toolkit.PropertyGrid.PropertyGrid.OnSelectedObjectChanged(DependencyObject o, DependencyPropertyChangedEventArgs e)
at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
at Xceed.Wpf.Toolkit.PropertyGrid.PropertyGrid.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)
at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType)
at System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType, Boolean isInternal)
at System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value)
etc