Is it possible to have multiple threaded forms as MDIChild? I have an ActiveX control in MdiChild form that can take a lot of processing CPU, and would like to make that one control will not influence another control by using sample code below. But line frmDoc.MdiParent = Me throws cross threading exception.
Dim frmDoc As MDIChild
Dim newThread As New Thread(
Sub()
frmDoc = New MDIChild
frmDoc.MdiParent = Me '<- this line throws cross threading exception.
Application.Run(frmDoc)
End Sub
)
newThread.IsBackground = True
newThread.SetApartmentState(ApartmentState.STA)
newThread.Start()
Throws System.InvalidOperationException was unhandled:
Message=Cross-thread operation not valid:
Control 'FormMdiApp' accessed from a thread other than the thread it was created on.
Source=System.Windows.Forms