the AddMoreControls runs in a new Thread, the control (ctl) created in this function will not be in the same thread as the Panel (the UI Thread).
That's why I think you have the invalid operation.
You should include the creation of the control in the Invoked method.
Delegate Sub sAddMoreControl(ByVal myType as myType)
Private Sub AddMoreControls(byval myType as myType)
try
if GroupBox.InvokeRequired then
Dim d As New sAddMoreControl(AddressOf AddMoreControls)
GroupBox.Invoke(d, New Object() {myType})
else
Dim ctl As New MyControl
ctl.Name = "txt_1"
ctl.myType = myType
myPanel.add(ctl)
end if
Catch ex As Exception
msgbox (ex)
End Try
end sub
Sorry if I made some syntax error in VB.NET, I use C# syntax more.