Never ventured into Delegates much but of late I'm having to re-code some apps that use threading more and more.
I understand (or I think I do) the reasoning behind Delegates and why they are needed but am stuck at this simple little problem:
I have a form within a class library that I'm calling from the main program.
To use a very simple example, I want to test that things are working by updating a variable on the thread, so have the following:
On the main form itself, I have the following code:
Now that doesn't work, I still get the error about not being able to update because it's on a seperate thread, but, can someone explain to me what I'm doing wrong.
I understand (or I think I do) the reasoning behind Delegates and why they are needed but am stuck at this simple little problem:
I have a form within a class library that I'm calling from the main program.
To use a very simple example, I want to test that things are working by updating a variable on the thread, so have the following:
Public Delegate Sub CallBackDelegate(ByVal sb As System.Windows.Media.Brush)
Public Sub updateUI(ByVal sb As System.Windows.Media.Brush)
Dim a As New CallBackDelegate(AddressOf uui)
a.Invoke(sb)
End Sub
Private Sub uui(ByVal sb As System.Windows.Media.Brush)
Me.ColourOverlay = sb
End Sub
On the main form itself, I have the following code:
Private Shared Sub UpdateFromConfiguration()
Dim s As System.Windows.Media.Brush = System.Windows.Media.Brushes.Azure
naw.updateUI(s)
End Sub
Now that doesn't work, I still get the error about not being able to update because it's on a seperate thread, but, can someone explain to me what I'm doing wrong.