Put the following in the viewmodelBase
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
Protected Sub InvokeOnUIThread(action As System.Action) #If SILVERLIGHT Then If Deployment.Current.Dispatcher.CheckAccess Then action.Invoke() Else Deployment.Current.Dispatcher.BeginInvoke(action) End If #Else If action IsNot Nothing Then If System.Windows.Application.Current.Dispatcher.CheckAccess Then action.Invoke Else System.Windows.Application.Current.Dispatcher.BeginInvoke(action) End If End If #End If End Sub |
Example call
1 2 3 4 5 6 7 8 9 10 11 |
Controller.Messenger.Register(Of ClientDiscountTemplateUpdatedMessage)(Me, True, AddressOf HandleClientDiscountTemplateUpdatedMessage) Private Sub HandleClientDiscountTemplateUpdatedMessage(message As ClientDiscountTemplateUpdatedMessage) InvokeOnUIThread(Sub() ProcessPublicationSectionUpdatedMessage(message)) End Sub Private Sub ProcessPublicationSectionUpdatedMessage(message As ClientDiscountTemplateUpdatedMessage) 'Do something here End Sub |