Here Is My Code
Public th As New Thread(New ThreadStart(AddressOf StartFirstPrint))
Public th4 As New Thread(New ThreadStart(AddressOf sendFirstEmail))
Here is the code of StartFirstPrint and sendFirstEmail
Public Sub StartFirstPrint()
Do While thCont
Try
Dim frm As New frmPrint()
'frm.MdiParent = Me
frm.StartPrinting()
Catch ex As Exception
End Try
Loop
End Sub
Public Sub sendFirstEmail()
Do While thCont
Try
Dim frmSNDEmail As New frmEmail
frmSNDEmail.SendEmails()
Catch ex As Exception
End Try
Loop
End Sub
the thCont is a public boolean variable that specifies when to shop those threads.
If I access any control of frmPrint from StartPrinting and any control of frmEmail from SendEmails, will it be thread unsafe call?
StartPrinting is a public Sub of frmPrint and SendEmails is a public Sub of frmEmail
You can not access controls, because you would get an exception because of trying to access controls from a thread not being the thread they are created from. It doesn’t makr a difference that the method is inside the Form – it’s still called from a different thread.