vbv.net MultiThreading

Larry Brister
Larry Brister used Ask the Experts™
on
In a .Net console project
I pull in data from SQL server
And send emails through a Vendor (SendGrid)

I am running into a "bogdown" because of the HTML size.

Is there a way to multithread the SEND on the same DATATABLE that is sending the emails one at a time?

                        While dR4.Read()

                            EmailFrom = dR4("FromAddress")
                            EmailSubject = dR4("Subject")      
                           blah...blah...blah... bunch of setup and replace....
                           ' Send the email.
                                transportWeb.Deliver(myMessage)
                        End WHile
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Senior .Net Developer
Commented:
Private Sub Btn_Click() 

Dim emailThread As New Thread(AddressOf Me.SendEmails(MyDataTable))
emailThread.Start()

Exit Sub

Private Sub SendEmails(ByRef dt As DataTable)


    for each (row As dataRow in dt.Rows)
      ' do something
  next

End Sub

Open in new window

Shaun VermaakTechnical Specialist
Awarded 2017
Distinguished Expert 2018

Commented:
If you want to quickly do it without changing code, use my CommandThreader tool
https://www.experts-exchange.com/articles/30139/How-to-thread-single-threaded-applications.html
Larry Bristersr. Developer

Author

Commented:
Perfect

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial