Link to home
Start Free TrialLog in
Avatar of jeff Lee
jeff Lee

asked on

Create a new thread AddressOf a function with parameters in VB?

Hi,

  The following is my code-
Dim ThreadBegin As New ThreadStart(AddressOf SendMail(ui, "-1", "OTHER", mailTItle, mailContent.ToString(), ReceiverEmail, File, ""))  --->it show something went wrong.
Dim m_Thread As Thread = New Thread(ThreadBegin)
m_Thread.IsBackground = True
m_Thread.Name = "WorkerThread" + Now.ToShortTimeString()
m_Thread.Start()

Public Function SendMail(ByVal ui As UserInfo, ByVal strType As String, ByVal strDescription As String, ByVal strSubject As String, ByVal strBody As String, ByVal strTos As String, ByVal strCTos As String) As Boolean
      Return SendMail(ui, strType, strDescription, strSubject, strBody, strTos, "", strCTos, "")
End Function

   How can I pass the parameters for function SendMail? Thanks.
Avatar of ste5an
ste5an
Flag of Germany image

Please post the exact error  message..

Cause this sounds ,more like a failed sending attempt.
Avatar of jeff Lee
jeff Lee

ASKER

Hi ste5an,

  Thank you for your reply so soon. I am from non-English speaking country.I can't post the exact error message from visual studio 2019 in english.The error message just show I delivery wrong parameters.Something like that. I really don't know how to fix it.


  best regards,


  jeff
Stack trace, error code and a screenshot pleas.
As ste5an stated.  Please post the exact error you get.  We can still assist even if it is not in English.  ;)

But I think I spotted the potential issue.  Try this instead:
Dim ThreadBegin As New ThreadStart(AddressOf SendMail(ui, "-1", "OTHER", mailTItle, mailContent.ToString(), ReceiverEmail, File))

Open in new window


-saige-
User generated image
I appreciate your kind assistance. I am not sure the error message is helpful. In the meanwhile,I can't trace my code.The error is obvious.

Dim ThreadBegin As New ThreadStart(AddressOf SendMail(ui, "-1", "OTHER", mailTItle, mailContent.ToString(), ReceiverEmail, File))

Open in new window

It still can't work.

  Thanks all of you.


jeff
It supports one parameter to be passed to thread In vb.net. But when we need to pass more than one parameter ,how to do that? That's the point.

Anyone can help me? Thanks.
This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.