MIP exception when switching tabs in SC with the SCViewandWindow plugin

I tried to modify the SCViewandWindow plugin to switch the client tabs via an additional built-in UDP interface. In principle, it seems to work if I am already on the tab that I select, I do not get an error message. However, if I try to open another tab, this error message appears in the client: MIP plug-in exception in `SendMessage’.Exception Message: The calling thread cannot access this object because a different thread owns it. I tried the direct command and tried it indirectly by clicking the button in the dialog for switching which is included in the SCViewandWindow. Always the same result.

Details in the exception:

************** Outer Exception **************

Exception type:System.InvalidOperationException

Exception message:The calling thread cannot access this object because a different thread owns it.

Exception source:WindowsBase

Exception Target Site: VerifyAccess

at System.Windows.Threading.Dispatcher.VerifyAccess()

at System.Windows.DependencyObject.GetValue(DependencyProperty dp)

at System.Windows.Controls.Panel.get_IsItemsHost()

at System.Windows.Controls.ItemsControl.GetItemsOwnerInternal(DependencyObject element, ItemsControl& itemsControl)

at System.Windows.Controls.Panel.VerifyBoundState()

at System.Windows.Controls.Panel.get_InternalChildren()

at VideoOS.RemoteClient.Application.UI.Content.Grid.ContentGridWpf.set_GlobalSelectedGridControl(IContentHolderControlBase value)

at VideoOS.RemoteClient.Application.UI.Content.Grid.ContentGrid.UpdateGlobalSelectedViewItemState()

at VideoOS.RemoteClient.Application.Controllers.ApplicationController.GlobalSelectedViewItemChangedEventHandler.Invoke(Object sender, GlobalSelectedViewItemChangedEventArgs e)

at VideoOS.RemoteClient.Application.Controllers.ApplicationController.FireGlobalSelectedViewItemChangedEvent(IApplicationController selectedApplicationController)

at VideoOS.RemoteClient.Application.Controllers.ApplicationController.GlobalSelectedViewItemInternalOnly(ViewItemBase viewItem, IControllerManager selectedControllerManager)

at VideoOS.RemoteClient.Application.Controllers.ApplicationController.SetSelectedView(View view, Boolean force, Boolean revertToDefaultViewItems, IList`1 viewItemStates)

at VideoOS.RemoteClient.Application.Controllers.ApplicationController.set_SelectedView(View value)

at VideoOS.RemoteClient.Application.Controllers.WorkSpace.WorkSpaceController.SetWorkSpace(WorkSpaceItem item, Boolean setNewView, IList`1 viewItemStates, Boolean setVideoWall, Boolean notifyListeners, Boolean isFromLocalSource)

at VideoOS.RemoteClient.Application.Controllers.WorkSpace.WorkSpaceController.SetWorkSpace(Guid workSpaceId, Boolean setNewView, IList`1 viewItemStates, Boolean notifyListeners, Boolean isFromLocalSource)

at VideoOS.RemoteClient.Application.MIP.Manager.SCClientControl.set_ShownWorkSpace(Item value)

at VideoOS.RemoteClient.Application.MIP.Manager.MessageManager.ShowWorkSpaceHandler(Message message, FQID dest, FQID source)

at VideoOS.RemoteClient.Application.MIP.Manager.SCEnvironmentManager.ExecuteMessage(Message message, FQID destination, FQID sender, String logMessage)

************** System Info **************

Date and time: 09.06.2020 11:44:40

Machine Name: TOM-DELL

Processors count: 8

OS version: Microsoft Windows NT 6.2.9200.0

64 bit OS: True

64 bit process: True

IP address: ::1 (Tom-Dell)

Current user: TOM-DELL\Tom

_________________________________________________________________

Has someone an idea, what I have forgotten ?

Thanks and best regards

Tom

The reason for the error is that you are calling from a thread that is not the UI thread. Please use CallOnUiThread to ensure the action is executed on the UI thread.

https://doc.developer.milestonesys.com/html/index.html?base=miphelp/class_video_o_s_1_1_platform_1_1_client_control.html&tree=tree_search.html?search=uithread

Thank you very much, now it works like a charme !