Hello W.G. Ryan eMVP,
I've never tried so hard to get an exception to happen... but I suceeded
in it. :D I got the following exception.
An unhandled exception of type 'System.ArgumentException' occurred in system.windows.forms.dll
Additional information: Controls created on one thread cannot be parented
to a control on a different thread.
And this is what I did.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button1.Click
For i As Integer = 0 To 10
Dim t As New Thread(AddressOf Me.MyThreadSub)
t.Start()
Next
End Sub
Private Sub MyThreadSub()
Dim t As New TextBox
Me.Controls.Add(t)
End Sub
I do remember now that that's exactly what I did in my actual development
and got stuck for a while because I didn't know about that concept. Anyway...
I successfully got an exception to happen! Now I'm happy!
Keep trying ;-)
TiBA Solutions
www.tibasolutions.com | www.devbuzz.com | www.knowdotnet.com
"Hayato Iriumi" <hi*****@hotmail.com> wrote in message
news:32*********************@news.microsoft.com... It's a big taboo to manipulate Windows Form directly from another
thread and I did come across the issue in my actual development. My
colleague and I were talking about it this morning and we wanted to
see if we could
actually
get the exception to happen. So I did this sample in VB .NET.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs)
Handles Button1.Click
Dim t As New Thread(AddressOf Me.MyThreadSub)
t.Start()
End Sub
Private Sub MyThreadSub()
Button1.Text = "Test"
End Sub
Somehow, error is not happening... Now I'm confused...