Hi All
Have had a really good look around and cannot find any posts that have dealt with this issue.
I send messages to a message queue on the local machine with my application that listens for any new messages and reads/responds according.
I wanted to be able to use certain messages to open a new WPF window and other messages (in different queues) to control models on that new widow. I have been as far as the following code:
message receive event handler that opens new widow:
Dim newWindowThread As Thread = New Thread(AddressOf Me.Thread_start_new_timed_window)
newWindowThread.SetApartmentState(ApartmentState.STA)
newWindowThread.IsBackground = True
newWindowThread.Start()
Thread Event handler for above:
Private
Sub Thread_start_new_timed_window()frm_timed_scoreboard =
New timed_sports_scoreboard_V2frm_timed_scoreboard.Show()
System.Windows.Threading.Dispatcher.Run()
End Sub
Ongoing message receive event handler that will control model on new window:
frm_timed_scoreboard.get_time_data(court_data.countdown_time)
Dim newWindowEditThread As Thread = New Thread(AddressOf Me.Thread_update_timer)newWindowEditThread.SetApartmentState(ApartmentState.STA)
newWindowEditThread.IsBackground =
TruenewWindowEditThread.Start()
Thread event Handler for above:
Private
Sub Thread_update_timer()frm_timed_scoreboard.run_timer_changes()
System.Windows.Threading.Dispatcher.Run()
End Sub
Of course when the second thread is fired it creates a "The calling thread cannot access this object because a different thread owns it." Exception. Being new to WPF and the dispatcher I am not sure how to get past this
Any help or ideas would be great
Regards
Nick