Click here to Skip to main content
15,890,185 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
As of right now, I have a match merge statement that uses a 3 to 5 part match. it takes approximately 440 seconds to complete 152,000 matches. However, I am looking to do threading to decrease the amount of time it takes.

for my threading I have this:

Public Sub create_threads()

       Dim Threads As New List(Of Thread)
       Dim x As Long
       Dim newthread As String

       x = Temptable.Rows.Count / Environment.ProcessorCount
       x = Math.Ceiling(x)

       For total = 0 To Environment.ProcessorCount - 1
           I3 = x * total
           I4 = x * (total + 1)
           newthread = "thread" + total.ToString
           Dim t As New Thread(Sub() Match_Merge())
           t.Name = newthread
           Threads.Add(t)
           t.Start()
       Next

       For Each t As Thread In Threads
           t.Join()
       Next

   End Sub


The issue I think I am having is its not breaking up the work. What I am trying to accomplish is to set a dynamic method scenario. So when match merge is called it will be separate instances of it.

What I have tried:

I was looking into creating dynamic methods, trying to follow the example: .net - Calling a method within a dynamic method in VB.NET - Stack Overflow[^] but it did not work.
Posted
Updated 4-Jan-20 15:51pm

1 solution

If you want to do one task across threads, you clearly need to figure out a way to batch it and give different parts of it to different threads. Just calling the same method X times won't speed anything up
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900