0

I am Developing Auto Email Sending Program in VB.net Windows Application. The weird thing is that when debugger reaches to
Dim SMTP As New SmtpClient(_SMTP) this line it goes to the calling function again and the debugging Strip color changes to green from Yellow for Example:

Private Sub Send_Mail_To_Checker() <-- Debugger Jumps Here with Color changes to Green
'----Some code-------
SendMail()
 End Sub

  Public Sub SendMail()
      Dim Mail As New MailMessage
      _SMTP="smtp.gmail.com"
      Dim SMTP As New SmtpClient(_SMTP) '<-- Debugger Jumps from this 
 End Sub

Please Help

  • Are you getting any error's, that would be helpful to know. Also what is `_SMTP` declared as? Also please check this answer to see how to setup/sending email as this has been answer here on SO more than a few times: **https://stackoverflow.com/questions/22814590/sending-email-from-visual-basic/22853475#22853475** – Trevor Dec 21 '15 at 13:32

1 Answers1

0

If the debugger is going back to the start of the function without you expecting it ... It suggests that it is getting called multiple times.

I've seen this behaviour in a multithreaded environment - The breakpoint will fire each time a new thread is created and calls the sub.

To check, goto the Debug Menu -> Windows -> Threads. When the breakpoint is fired the first time, take a note of the threadid. Then check it against the next time. If the threadid is different each time then you're working in a multi threaded environment and may want to consider using semaphores to limit the amount of time a sub routine can be called in parallel.

Not sure why the color is changing from green to yellow though!

Mark G
  • 332
  • 3
  • 12