Multithreading and classes

lothos12345

Junior Contributor
Joined
May 2, 2002
Messages
294
Location
Texas
I have the following calls in several Subs.

Call initcomboboxes("header", tindex)
Call initcomboboxes("footer", tindex)
Call initcomboboxes("sigblock", tindex)

Theses calls of course call the sub procedure below. All its doing is loading combo boxes. I want to multithread this code thus making the load time of the program quicker. I was toying around with the ideal of using a class unforunately I am not quite sure how to do this. Any help given would be greatly appreciated.

Private Sub initcomboboxes(ByVal boxtoload As String, Optional ByVal letterselected As Integer = 0)
Dim SqlDA As New SqlClient.SqlDataAdapter
Dim SqlCmd As New SqlClient.SqlCommand
Dim SqlCmdPrm As New SqlClient.SqlParameter
Dim Sqlds As New DataSet
Dim vparameter As String
Dim cloop As Integer

Try
Select Case boxtoload
Case "lettertype"
vparameter = "glettertype"
Case "template"
vparameter = "gTemplate"
Case "header"
vparameter = "gHeader"
Case "footer"
vparameter = "gFooter"
Case "sigblock"
vparameter = "gSigBlock"
End Select

If sqlconnection2.State = ConnectionState.Closed Then sqlconnection2.Open()
SqlCmd = sqlconnection2.CreateCommand
SqlCmd.CommandType = CommandType.StoredProcedure
SqlCmd.CommandText = "TMCFillPIPTProgList"
SqlCmdPrm = SqlCmd.Parameters.Add("@getwhat", SqlDbType.VarChar)
SqlCmdPrm.Value = vparameter
SqlCmdPrm = SqlCmd.Parameters.Add("@ltrtype", SqlDbType.Int)
SqlCmdPrm.Value = letterselected
SqlDA.SelectCommand = SqlCmd
SqlDA.Fill(Sqlds, "dsmain")
sqlconnection2.Close()
System.GC.Collect()

Select Case boxtoload
Case "lettertype"
ComboBox5.DataSource = Sqlds.Tables("dsmain")
ComboBox5.DisplayMember = Sqlds.Tables("dsmain").Columns("Listname").ToString
ComboBox5.ValueMember = Sqlds.Tables("dsmain").Columns("PtProgListId").ToString
Case "template"
ComboBox1.DataSource = Sqlds.Tables("dsmain")
ComboBox1.DisplayMember = Sqlds.Tables("dsmain").Columns("TemplateName").ToString
ComboBox1.ValueMember = Sqlds.Tables("dsmain").Columns("PtProgTemplateId").ToString
Case "header"
ComboBox2.DataSource = Sqlds.Tables("dsmain")
ComboBox2.DisplayMember = Sqlds.Tables("dsmain").Columns("Listname").ToString
ComboBox2.ValueMember = Sqlds.Tables("dsmain").Columns("PtProgListId").ToString
Case "footer"
ComboBox3.DataSource = Sqlds.Tables("dsmain")
ComboBox3.DisplayMember = Sqlds.Tables("dsmain").Columns("Listname").ToString
ComboBox3.ValueMember = Sqlds.Tables("dsmain").Columns("PtProgListId").ToString
Case "sigblock"
ComboBox4.DataSource = Sqlds.Tables("dsmain")
ComboBox4.DisplayMember = Sqlds.Tables("dsmain").Columns("Listname").ToString
ComboBox4.ValueMember = Sqlds.Tables("dsmain").Columns("PtProgListId").ToString
End Select

Catch ex As Exception
Call errhandler(ex.Message, ex.StackTrace, ex.Source)
End Try

End Sub
 
Back
Top