Multi thread tab control

IneedaSmoke

Active member
Joined
Mar 4, 2008
Messages
26
Programming Experience
Beginner
Hey all, wondering if anyone knew whether or not multi thread tab control could work.

I have a tab control that I create tabs programmatically. I tried creating the tabs as new threads, but i'm getting thread conflict errors.

HTML:
    Private Sub loadTCTabs(ByVal productList As ArrayList)

        For Each item In productList
            positionCounter.addALClasses(item)
            Dim newThread As Thread
            newThread = New Thread(AddressOf createTab)
            newThread.Start()

        Next




    End Sub

    Private Sub createTab()


        Dim newTab As New TabPage
        Dim newDGV As New DataGridView
        Dim positionData As New ArrayList
        positionData = positionCounter.getCurrentValueClassCounterPosition
        newTab.Text = positionData(1)



        newTab.Controls.Add(newDGV)
        newDGV.Width = 815
        newDGV.Height = 606
        newDGV.Location = New System.Drawing.Point(0, 3)



        tcOutput.TabPages.Add(newTab)


    End Sub
 
You have to create the controls in UI thread - else you would have to destroy the window handles, move them to UI thread and create new window handles there, I wouldn't recommend it. Time consuming data processing you can do in other threads.
 
Ok, thanks. I got all these processors just sitting there lol. I'll multithread the calculations in the datagrids. I'm not maxing the one proc though so I guess it's my sql calls that are my bottleneck but i'm trying to get in the habit of multithreading whenever I can.
 
Back
Top