I am working with C# and I have a user control in WPF, my problem is that when I close the form where my usercontrol is instantiated I get the following error in the base.Dispose(disposing) line of the .Designer.cs file of the form.
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.
************** Exception Text **************
System.InvalidOperationException: The calling thread cannot access this object because a different thread owns it.
at System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value)
at System.Windows.Input.FocusManager.SetFocusedElement(DependencyObject element, IInputElement value)
at System.Windows.Forms.Integration.ElementHost.OnLeave(EventArgs e)
This does not occur when I don't instantiate the WPF control. To instantiate the usercontrol I use the ElementHost class to integrate the WPF control in my WindowsForm application.
I don't know if anyone has an advice to resolve this problem?
Thanks in advance.