Z
Zanna
Hi all!
I got a little problem with multithreading.
I have a form with tree labels that create an instance of a class with a
new thread in it.
This new thread do some computation and then it raises an event of its
class that is trapped by the main form.
In this form I do this:
Private Delegate Sub SafeInvoker()
Public Sub Safe()
Me.Label1.Text = "ok"
Me.Label2.Text = "ok"
Me.Label3.Text = "ok"
End Sub
Private Sub MyThreadEvent(ByVal sender As Object, ByVal e As
EventArgs) Handles MyObj.MyThreadEvent
Dim del As New SafeInvoker(AddressOf Safe)
Me.Invoke(del)
End Sub
When I do Me.Invoke(del) I get ArgumentException.
Why?
How can I do it work?
Thanks
I got a little problem with multithreading.
I have a form with tree labels that create an instance of a class with a
new thread in it.
This new thread do some computation and then it raises an event of its
class that is trapped by the main form.
In this form I do this:
Private Delegate Sub SafeInvoker()
Public Sub Safe()
Me.Label1.Text = "ok"
Me.Label2.Text = "ok"
Me.Label3.Text = "ok"
End Sub
Private Sub MyThreadEvent(ByVal sender As Object, ByVal e As
EventArgs) Handles MyObj.MyThreadEvent
Dim del As New SafeInvoker(AddressOf Safe)
Me.Invoke(del)
End Sub
When I do Me.Invoke(del) I get ArgumentException.
Why?
How can I do it work?
Thanks