Hi,
We have a requirement to open two windows in different UI threads.
Suppose,
X Window opens in Main thread
Y window opens in another thread
Now we have a tool window in both X window and Y window.
While we are trying to float the tool window programtaically in Y window using "toolWindow.Float()" we are getting following exception.When we tried to float the toolwindow in X window, it works fine with toolWindow.Float().Also the same error threading errors occurs when we double click on the Y Window toolWindow.
Please suggest any solution for this problem as this is becoming a Show Stopper issue for our application. Your help is highly appreciable. Waiting for your earliest response.
System.InvalidOperationException was unhandled
Message=The calling thread cannot access this object because a different thread owns it.
Source=WindowsBase
StackTrace:
at System.Windows.Threading.Dispatcher.VerifyAccess()
at #Ci.#Bi.#1z(Window #sb)
at #Ci.#Bi.#0z(Rect #Bo)
at ActiproSoftware.Windows.Controls.Docking.Primitives.RaftingWindow.SnapToScreen()
at ActiproSoftware.Windows.Controls.Docking.DockSite.#Tt(#ki #4j, DependencyObject #lp, Nullable'1 #2cc, Nullable'1 #xe, FloatSizingBehavior #dFf, Boolean #cFf)
at ActiproSoftware.Windows.Controls.Docking.DockSite.#St(DependencyObject #lp, Nullable'1 #2cc, Nullable'1 #xe, FloatSizingBehavior #dFf, Boolean #cFf)
at ActiproSoftware.Windows.Controls.Docking.DockSite.#St(DependencyObject #lp, Nullable'1 #2cc, FloatSizingBehavior #dFf, Boolean #cFf)
at ActiproSoftware.Windows.Controls.Docking.Primitives.RaftableDockingWindowContainer.Float(FloatSizingBehavior behavior)
at ActiproSoftware.Windows.Controls.Docking.Primitives.RaftableDockingWindowContainer.#Gq(Object #xhb, MouseButtonEventArgs #yhb)
at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
at System.Windows.UIElement.ReRaiseEventAs(DependencyObject sender, RoutedEventArgs args, RoutedEvent newEvent)
at System.Windows.UIElement.OnMouseDownThunk(Object sender, MouseButtonEventArgs e)
at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
at System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)
at System.Windows.Input.InputManager.ProcessStagingArea()
at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
at System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)
at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at System.Windows.Interop.HwndSource.InputFilterMessage(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)
at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
at System.Windows.Threading.Dispatcher.Run()
at DockingApplication.OpenNewThreadTW.Open() in D:\DockingApplication\DockingApplication\OpenNewThreadTW.xaml.cs:line 43
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException: