|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Controls created on one thread cannot (inoke setup)What is the best way to re-write this code to avoid the
'Controls created on one thread cannot be parented to a control on a different thread.' error? Private Sub SendCMTStoCore(ByVal Cmts As String) Dim threadMillhouseBridge As New MillhouseCore.ShowCMTSBridge(Cmts, AddressOf FormatReturnCMTSInfo) Dim threadCMTSScan As New Thread(AddressOf threadMillhouseBridge.BeginCMTSScan) threadCMTSScan.Name = intThreadCounterMill.ToString threadCMTSScan.Start() intThreadCounterMill += 1 End Sub Create both controls on the same thread? Or, create the controls on the
main process thread; create threads to do whatever work they are supposed to do and use delegates to invoke methods on the controls. Show quoteHide quote "pmclinn" <pmcl***@gmail.com> wrote in message news:1120231006.141299.145610@g43g2000cwa.googlegroups.com... > What is the best way to re-write this code to avoid the > 'Controls created on one thread cannot be parented to a control on a > different thread.' error? > > > Private Sub SendCMTStoCore(ByVal Cmts As String) > Dim threadMillhouseBridge As New > MillhouseCore.ShowCMTSBridge(Cmts, AddressOf FormatReturnCMTSInfo) > Dim threadCMTSScan As New Thread(AddressOf > threadMillhouseBridge.BeginCMTSScan) > threadCMTSScan.Name = intThreadCounterMill.ToString > > threadCMTSScan.Start() > intThreadCounterMill += 1 > End Sub > |
|||||||||||||||||||||||