Looks like RadDragAndDropManager is not ThreadStatic which causes application crash as We have UI in two different threads.
I have RadDragAndDropManager.EnableNativeDrag = true set in my Base control Constructor.
Now that base control is used at multiple places in my application.
In our main UI thread we have this control and from this thread we started another thread which has UI and in that window we make use of our control at many places in various window forms. And so whenever we open a window which contain that base control lookslike RadDragAndManager call the reset function on DesktopDragDropProvider object.
But when I go back to first UI Thread and click on the control that is using RadDragAndDropManager UE occurs.
************** Exception Text
**************
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.DependencyObject.GetValue(DependencyProperty dp)
at
System.Windows.Controls.ContentControl.get_Content()
at
Telerik.Windows.Controls.DragDrop.UndetectableWindow.set_Child(FrameworkElement
value)
at
Telerik.Windows.Controls.DragDrop.DesktopDragDropProvider.Reset()
at
Telerik.Windows.Controls.DragDrop.DesktopDragDropProvider.OnLeftMouseButtonUp(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.ReRaiseEventAs(DependencyObject sender, RoutedEventArgs
args, RoutedEvent newEvent)
at
System.Windows.UIElement.CrackMouseButtonEventAndReRaiseEvent(DependencyObject
sender, MouseButtonEventArgs e)
at
System.Windows.UIElement.OnMouseUpThunk(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.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, Int32
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, Boolean isSingleParameter)
at
System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate
callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
at System.Windows.Threading.Dispatcher.WrappedInvoke(Delegate callback, Object
args, Boolean isSingleParameter, Delegate catchHandler)
at
System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority,
TimeSpan timeout, Delegate method, Object args, Boolean isSingleParameter)
at System.Windows.Threading.Dispatcher.Invoke(DispatcherPriority priority,
Delegate method, Object arg)
at
MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam,
IntPtr lParam)
at
System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at
System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32
dwComponentID, Int32 reason, Int32 pvLoopData)
at
System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason,
ApplicationContext context)
at
System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason,
ApplicationContext context)
at System.Windows.Forms.Application.Run(Form
mainForm)
at Xm8.App.X.Program.ShowControlCenter(ControlCenterParameters
ccParams)
at Xm8.App.X.Program.ShowCC(Object parameter)
at
System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at
System.Threading.ExecutionContext.Run(ExecutionContext executionContext,
ContextCallback callback, Object state)
at
System.Threading.ThreadHelper.ThreadStart(Object obj)
In my understanding RadDragAndDropManager should be ThreadStatic rather than just the static. that might solve the problem.
Regards
Sanket